mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-24 17:40:43 +01:00
Merge pull request #5970 from mrgoldy/ticket/16472-master
[ticket/16472] [Master] Remove UI tests and php-webdriver/webdriver
This commit is contained in:
commit
f3f3d0f9a9
@ -114,10 +114,6 @@ before_test:
|
||||
sqlite3 c:\projects\test.db "create table aTable(field1 int); drop table aTable;"
|
||||
$data = "<?php`n`n`$dbms = 'phpbb\\db\\driver\\sqlite3';`n`$dbhost = 'c:\\projects\\test.db';`n`$dbport = '';`n`$dbname = '';`n`$dbuser = '';`n`$dbpasswd = '';`n`$phpbb_functional_url = 'http://phpbb.test/';"; $data | Out-File -Encoding "Default" "c:\\projects\\phpbb\\tests\\test_config.php"
|
||||
}
|
||||
|
||||
# Install PhantomJS
|
||||
choco install phantomjs -y
|
||||
Start-Process "phantomjs" "--webdriver=8910" | Out-Null
|
||||
- ps: |
|
||||
cd c:\projects\phpbb\phpBB
|
||||
(Get-Content c:\projects\phpbb\phpBB\web.config).replace("<configuration>", "<configuration>`n`t<system.web>`n`t`t<customErrors mode=`"Off`"/>`n`t</system.web>") | Set-Content c:\projects\phpbb\phpBB\web.config
|
||||
|
@ -44,7 +44,6 @@ install:
|
||||
before_script:
|
||||
- travis/setup-database.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
|
||||
- travis/setup-ldap.sh $SLOWTESTS
|
||||
- phantomjs --webdriver=8910 > /dev/null &
|
||||
|
||||
script:
|
||||
- travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
|
||||
|
@ -54,7 +54,6 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"fabpot/goutte": "~3.2",
|
||||
"php-webdriver/webdriver": "~1.8",
|
||||
"laravel/homestead": "~7.0",
|
||||
"phing/phing": "~2.4",
|
||||
"phpunit/dbunit": "~4.0",
|
||||
|
69
phpBB/composer.lock
generated
69
phpBB/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8cf3a98497a4edb83ea657f876902cca",
|
||||
"content-hash": "0090dbf57acf8d5b9b224bff16a089ff",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bantu/ini-get-wrapper",
|
||||
@ -862,7 +862,7 @@
|
||||
"oauth",
|
||||
"security"
|
||||
],
|
||||
"time": "2016-07-12T22:15:00+00:00"
|
||||
"time": "2018-02-14T22:37:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "marc1706/fast-image-size",
|
||||
@ -3942,71 +3942,6 @@
|
||||
],
|
||||
"time": "2020-02-03T18:50:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-webdriver/webdriver",
|
||||
"version": "1.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-webdriver/php-webdriver.git",
|
||||
"reference": "3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab",
|
||||
"reference": "3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"php": "^5.6 || ~7.0",
|
||||
"symfony/polyfill-mbstring": "^1.12",
|
||||
"symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"jakub-onderka/php-parallel-lint": "^1.0",
|
||||
"php-coveralls/php-coveralls": "^2.0",
|
||||
"php-mock/php-mock-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
|
||||
"sminnee/phpunit-mock-objects": "^3.4",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/var-dumper": "^3.3 || ^4.0 || ^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-SimpleXML": "For Firefox profile creation"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.8.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Facebook\\WebDriver\\": "lib/"
|
||||
},
|
||||
"files": [
|
||||
"lib/Exception/TimeoutException.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.",
|
||||
"homepage": "https://github.com/php-webdriver/php-webdriver",
|
||||
"keywords": [
|
||||
"Chromedriver",
|
||||
"geckodriver",
|
||||
"php",
|
||||
"selenium",
|
||||
"webdriver"
|
||||
],
|
||||
"time": "2020-03-04T14:40:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
"version": "2.0.5",
|
||||
|
@ -15,7 +15,6 @@
|
||||
<directory suffix="_test.php">./tests</directory>
|
||||
<exclude>./tests/functional</exclude>
|
||||
<exclude>./tests/lint_test.php</exclude>
|
||||
<exclude>./tests/ui</exclude>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB Functional Tests">
|
||||
<directory suffix="_test.php">./tests/functional</directory>
|
||||
@ -23,9 +22,6 @@
|
||||
<testsuite name="phpBB Lint Test">
|
||||
<file>./tests/lint_test.php</file>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB UI Tests">
|
||||
<directory suffix="_test.php">./tests/ui</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
|
@ -204,6 +204,11 @@ line:
|
||||
Port 8910 is the default port that will be used by UI tests to connect
|
||||
to the WebDriver instance.
|
||||
|
||||
Please note that PhantomJS does not support ECMAScript 2015 (ES 6th Edition).
|
||||
Tests using PhantomJS have been removed in phpBB 3.3.2,
|
||||
and the WebDriver dependency is removed in phpBB 4.
|
||||
UI tests will take a different form in phpBB 4.
|
||||
|
||||
More Information
|
||||
================
|
||||
|
||||
|
@ -40,7 +40,6 @@ require_once 'test_framework/phpbb_test_case.php';
|
||||
require_once 'test_framework/phpbb_database_test_case.php';
|
||||
require_once 'test_framework/phpbb_database_test_connection_manager.php';
|
||||
require_once 'test_framework/phpbb_functional_test_case.php';
|
||||
require_once 'test_framework/phpbb_ui_test_case.php';
|
||||
|
||||
if (file_exists(__DIR__ . '/vendor/autoload.php'))
|
||||
{
|
||||
|
@ -1,744 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
use Facebook\WebDriver\WebDriverBy;
|
||||
use Facebook\WebDriver\Exception\WebDriverCurlException;
|
||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||
|
||||
require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php';
|
||||
|
||||
class phpbb_ui_test_case extends phpbb_test_case
|
||||
{
|
||||
static protected $host = '127.0.0.1';
|
||||
static protected $port = 8910;
|
||||
|
||||
/**
|
||||
* @var RemoteWebDriver
|
||||
*/
|
||||
static protected $webDriver;
|
||||
|
||||
static protected $config;
|
||||
static protected $root_url;
|
||||
static protected $already_installed = false;
|
||||
static protected $install_success = false;
|
||||
protected $cache = null;
|
||||
protected $db = null;
|
||||
protected $extension_manager = null;
|
||||
|
||||
/**
|
||||
* Session ID for current test's session (each test makes its own)
|
||||
* @var string
|
||||
*/
|
||||
protected $sid;
|
||||
|
||||
/**
|
||||
* Language array used by phpBB
|
||||
* @var array
|
||||
*/
|
||||
protected $lang = array();
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver'))
|
||||
{
|
||||
self::markTestSkipped(
|
||||
'Could not find RemoteWebDriver class.'
|
||||
);
|
||||
}
|
||||
|
||||
self::$config = phpbb_test_case_helpers::get_test_config();
|
||||
self::$root_url = self::$config['phpbb_functional_url'];
|
||||
|
||||
// Important: this is used both for installation and by
|
||||
// test cases for querying the tables.
|
||||
// Therefore table prefix must be set before a board is
|
||||
// installed, and also before each test case is run.
|
||||
self::$config['table_prefix'] = 'phpbb_';
|
||||
|
||||
if (!isset(self::$config['phpbb_functional_url']))
|
||||
{
|
||||
self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
|
||||
}
|
||||
|
||||
try {
|
||||
$capabilities = DesiredCapabilities::chrome();
|
||||
$chromeOptions = (new ChromeOptions)->addArguments(['headless', 'disable-gpu']);
|
||||
$capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
|
||||
self::$webDriver = RemoteWebDriver::create(
|
||||
self::$host . ':' . self::$port,
|
||||
$capabilities,
|
||||
30 * 1000, // 30 seconds connection timeout
|
||||
30 * 1000 // 30 seconds request timeout
|
||||
);
|
||||
} catch (WebDriverCurlException $e) {
|
||||
self::markTestSkipped('PhantomJS webserver is not running.');
|
||||
}
|
||||
|
||||
if (!self::$already_installed)
|
||||
{
|
||||
self::install_board();
|
||||
self::$already_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array List of extensions that should be set up
|
||||
*/
|
||||
static protected function setup_extensions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!self::$install_success)
|
||||
{
|
||||
$this->fail('Installing phpBB has failed.');
|
||||
}
|
||||
|
||||
// Clear the language array so that things
|
||||
// that were added in other tests are gone
|
||||
$this->lang = array();
|
||||
$this->add_lang('common');
|
||||
|
||||
$db = $this->get_db();
|
||||
|
||||
foreach (static::setup_extensions() as $extension)
|
||||
{
|
||||
$this->purge_cache();
|
||||
|
||||
$sql = 'SELECT ext_active
|
||||
FROM ' . EXT_TABLE . "
|
||||
WHERE ext_name = '" . $db->sql_escape($extension). "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$status = (bool) $db->sql_fetchfield('ext_active');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$status)
|
||||
{
|
||||
$this->install_ext($extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
if ($this->db instanceof \phpbb\db\driver\driver_interface)
|
||||
{
|
||||
// Close the database connections again this test
|
||||
$this->db->sql_close();
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
return self::$webDriver;
|
||||
}
|
||||
|
||||
public function visit($path)
|
||||
{
|
||||
// Retry three times on curl issues, e.g. timeout
|
||||
$attempts = 0;
|
||||
$retries = 3;
|
||||
|
||||
while (true)
|
||||
{
|
||||
$attempts++;
|
||||
try
|
||||
{
|
||||
$this->getDriver()->get(self::$root_url . $path);
|
||||
break;
|
||||
}
|
||||
catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception)
|
||||
{
|
||||
if ($attempts >= $retries)
|
||||
{
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static protected function recreate_database($config)
|
||||
{
|
||||
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
|
||||
$db_conn_mgr->recreate_db();
|
||||
}
|
||||
|
||||
public function find_element($type, $value)
|
||||
{
|
||||
return $this->getDriver()->findElement(WebDriverBy::$type($value));
|
||||
}
|
||||
|
||||
public function submit($type = 'id', $value = 'submit')
|
||||
{
|
||||
$element = $this->find_element($type, $value);
|
||||
$element->click();
|
||||
}
|
||||
|
||||
static protected function install_board()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $db;
|
||||
|
||||
self::recreate_database(self::$config);
|
||||
|
||||
$config_file = $phpbb_root_path . "config.$phpEx";
|
||||
$config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
|
||||
$config_file_test = $phpbb_root_path . "config_test.$phpEx";
|
||||
|
||||
if (file_exists($config_file))
|
||||
{
|
||||
if (!file_exists($config_file_dev))
|
||||
{
|
||||
rename($config_file, $config_file_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($config_file);
|
||||
}
|
||||
}
|
||||
|
||||
$install_config_file = $phpbb_root_path . 'store/install_config.php';
|
||||
|
||||
if (file_exists($install_config_file))
|
||||
{
|
||||
unlink($install_config_file);
|
||||
}
|
||||
|
||||
$container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
|
||||
$container = $container_builder
|
||||
->with_environment('installer')
|
||||
->without_extensions()
|
||||
->without_cache()
|
||||
->with_custom_parameters([
|
||||
'core.disable_super_globals' => false,
|
||||
'installer.create_config_file.options' => [
|
||||
'debug' => true,
|
||||
'environment' => 'test',
|
||||
],
|
||||
'cache.driver.class' => 'phpbb\cache\driver\file'
|
||||
])
|
||||
->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx))
|
||||
->without_compiled_container()
|
||||
->get_container();
|
||||
|
||||
$container->register('installer.install_finish.notify_user')->setSynthetic(true);
|
||||
$container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task());
|
||||
$container->register('installer.install_finish.install_extensions')->setSynthetic(true);
|
||||
$container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task());
|
||||
$container->compile();
|
||||
|
||||
$language = $container->get('language');
|
||||
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting'));
|
||||
|
||||
$iohandler_factory = $container->get('installer.helper.iohandler_factory');
|
||||
$iohandler_factory->set_environment('cli');
|
||||
$iohandler = $iohandler_factory->get();
|
||||
|
||||
$parseURL = parse_url(self::$config['phpbb_functional_url']);
|
||||
|
||||
$output = new \Symfony\Component\Console\Output\NullOutput();
|
||||
$style = new \Symfony\Component\Console\Style\SymfonyStyle(
|
||||
new \Symfony\Component\Console\Input\ArrayInput(array()),
|
||||
$output
|
||||
);
|
||||
$iohandler->set_style($style, $output);
|
||||
|
||||
$installer = $container->get('installer.installer.install');
|
||||
$installer->set_iohandler($iohandler);
|
||||
|
||||
// Set data
|
||||
$iohandler->set_input('admin_name', 'admin');
|
||||
$iohandler->set_input('admin_pass1', 'adminadmin');
|
||||
$iohandler->set_input('admin_pass2', 'adminadmin');
|
||||
$iohandler->set_input('board_email', 'nobody@example.com');
|
||||
$iohandler->set_input('submit_admin', 'submit');
|
||||
|
||||
$iohandler->set_input('default_lang', 'en');
|
||||
$iohandler->set_input('board_name', 'yourdomain.com');
|
||||
$iohandler->set_input('board_description', 'A short text to describe your forum');
|
||||
$iohandler->set_input('submit_board', 'submit');
|
||||
|
||||
$iohandler->set_input('dbms', str_replace('phpbb\db\driver\\', '', self::$config['dbms']));
|
||||
$iohandler->set_input('dbhost', self::$config['dbhost']);
|
||||
$iohandler->set_input('dbport', self::$config['dbport']);
|
||||
$iohandler->set_input('dbuser', self::$config['dbuser']);
|
||||
$iohandler->set_input('dbpasswd', self::$config['dbpasswd']);
|
||||
$iohandler->set_input('dbname', self::$config['dbname']);
|
||||
$iohandler->set_input('table_prefix', self::$config['table_prefix']);
|
||||
$iohandler->set_input('submit_database', 'submit');
|
||||
|
||||
$iohandler->set_input('email_enable', true);
|
||||
$iohandler->set_input('smtp_delivery', '1');
|
||||
$iohandler->set_input('smtp_host', 'nxdomain.phpbb.com');
|
||||
$iohandler->set_input('smtp_auth', 'PLAIN');
|
||||
$iohandler->set_input('smtp_user', 'nxuser');
|
||||
$iohandler->set_input('smtp_pass', 'nxpass');
|
||||
$iohandler->set_input('submit_email', 'submit');
|
||||
|
||||
$iohandler->set_input('cookie_secure', '0');
|
||||
$iohandler->set_input('server_protocol', '0');
|
||||
$iohandler->set_input('force_server_vars', $parseURL['scheme'] . '://');
|
||||
$iohandler->set_input('server_name', $parseURL['host']);
|
||||
$iohandler->set_input('server_port', isset($parseURL['port']) ? (int) $parseURL['port'] : 80);
|
||||
$iohandler->set_input('script_path', $parseURL['path']);
|
||||
$iohandler->set_input('submit_server', 'submit');
|
||||
|
||||
$installer->run();
|
||||
|
||||
copy($config_file, $config_file_test);
|
||||
|
||||
self::$install_success = true;
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/install_config.php'))
|
||||
{
|
||||
self::$install_success = false;
|
||||
@unlink($phpbb_root_path . 'store/install_config.php');
|
||||
}
|
||||
|
||||
if (file_exists($phpbb_root_path . 'cache/install_lock'))
|
||||
{
|
||||
@unlink($phpbb_root_path . 'cache/install_lock');
|
||||
}
|
||||
|
||||
global $phpbb_container;
|
||||
$phpbb_container->reset();
|
||||
|
||||
$blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader'];
|
||||
|
||||
foreach (array_keys($GLOBALS) as $key)
|
||||
{
|
||||
if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true))
|
||||
{
|
||||
unset($GLOBALS[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function install_ext($extension)
|
||||
{
|
||||
$this->add_lang('acp/extensions');
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$ext_path = str_replace('/', '%2F', $extension);
|
||||
|
||||
$this->visit('adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
|
||||
$this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset.submit-buttons input.button2')));
|
||||
|
||||
$this->find_element('cssSelector', "input[value='" . $this->lang('EXTENSION_ENABLE') . "']")->submit();
|
||||
|
||||
try
|
||||
{
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
|
||||
// Wait for extension to be fully enabled
|
||||
while (count($meta_refresh))
|
||||
{
|
||||
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
|
||||
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
}
|
||||
}
|
||||
catch (\Facebook\WebDriver\Exception\NoSuchElementException $e)
|
||||
{
|
||||
// Probably no refresh triggered
|
||||
}
|
||||
|
||||
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText());
|
||||
|
||||
$this->logout();
|
||||
}
|
||||
|
||||
public function disable_ext($extension)
|
||||
{
|
||||
$this->add_lang('acp/extensions');
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$ext_path = str_replace('/', '%2F', $extension);
|
||||
|
||||
$this->visit('adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
|
||||
$this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset.submit-buttons input.button2')));
|
||||
|
||||
$this->find_element('cssSelector', "input[value='" . $this->lang('EXTENSION_DISABLE') . "']")->submit();
|
||||
|
||||
try
|
||||
{
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
|
||||
// Wait for extension to be fully enabled
|
||||
while (count($meta_refresh))
|
||||
{
|
||||
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
|
||||
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
}
|
||||
}
|
||||
catch (\Facebook\WebDriver\Exception\NoSuchElementException $e)
|
||||
{
|
||||
// Probably no refresh triggered
|
||||
}
|
||||
|
||||
$this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText());
|
||||
|
||||
$this->logout();
|
||||
}
|
||||
|
||||
public function delete_ext_data($extension)
|
||||
{
|
||||
$this->add_lang('acp/extensions');
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$ext_path = str_replace('/', '%2F', $extension);
|
||||
|
||||
$this->visit('adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
|
||||
$this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset.submit-buttons input.button2')));
|
||||
|
||||
$this->find_element('cssSelector', "input[value='" . $this->lang('EXTENSION_DELETE_DATA') . "']")->submit();
|
||||
|
||||
try
|
||||
{
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
|
||||
// Wait for extension to be fully enabled
|
||||
while (count($meta_refresh))
|
||||
{
|
||||
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
|
||||
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
|
||||
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
|
||||
}
|
||||
}
|
||||
catch (\Facebook\WebDriver\Exception\NoSuchElementException $e)
|
||||
{
|
||||
// Probably no refresh triggered
|
||||
}
|
||||
|
||||
$this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText());
|
||||
|
||||
$this->logout();
|
||||
}
|
||||
|
||||
public function uninstall_ext($extension)
|
||||
{
|
||||
$this->disable_ext($extension);
|
||||
$this->delete_ext_data($extension);
|
||||
}
|
||||
|
||||
protected function get_cache_driver()
|
||||
{
|
||||
if (!$this->cache)
|
||||
{
|
||||
global $phpbb_container, $phpbb_root_path;
|
||||
|
||||
$phpbb_container = new phpbb_mock_container_builder();
|
||||
$phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
|
||||
$phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
|
||||
|
||||
$this->cache = new \phpbb\cache\driver\file;
|
||||
}
|
||||
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
protected function purge_cache()
|
||||
{
|
||||
$cache = $this->get_cache_driver();
|
||||
|
||||
$cache->purge();
|
||||
$cache->unload();
|
||||
$cache->load();
|
||||
}
|
||||
|
||||
protected function get_extension_manager()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$db = $this->get_db();
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($this->db);
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$migrator = new \phpbb\db\migrator(
|
||||
$container,
|
||||
$config,
|
||||
$db,
|
||||
$db_tools,
|
||||
self::$config['table_prefix'] . 'migrations',
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
self::$config['table_prefix'],
|
||||
phpbb_database_test_case::get_core_tables(),
|
||||
array(),
|
||||
new \phpbb\db\migration\helper()
|
||||
);
|
||||
$container->set('migrator', $migrator);
|
||||
$container->set('dispatcher', new phpbb_mock_event_dispatcher());
|
||||
$user = new \phpbb\user('\phpbb\datetime');
|
||||
|
||||
$extension_manager = new \phpbb\extension\manager(
|
||||
$container,
|
||||
$db,
|
||||
$config,
|
||||
$user,
|
||||
self::$config['table_prefix'] . 'ext',
|
||||
dirname(__FILE__) . '/',
|
||||
$phpEx,
|
||||
$this->get_cache_driver()
|
||||
);
|
||||
|
||||
return $extension_manager;
|
||||
}
|
||||
|
||||
protected function get_db()
|
||||
{
|
||||
// so we don't reopen an open connection
|
||||
if (!($this->db instanceof \phpbb\db\driver\driver_interface))
|
||||
{
|
||||
$dbms = self::$config['dbms'];
|
||||
/** @var \phpbb\db\driver\driver_interface $db */
|
||||
$db = new $dbms();
|
||||
$db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
|
||||
$this->db = $db;
|
||||
}
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
protected function logout()
|
||||
{
|
||||
$this->add_lang('ucp');
|
||||
|
||||
if (empty($this->sid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->visit('ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||
$this->assertContains($this->lang('REGISTER'), $this->getDriver()->getPageSource());
|
||||
unset($this->sid);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to the ACP
|
||||
* You must run login() before calling this.
|
||||
*/
|
||||
protected function admin_login($username = 'admin')
|
||||
{
|
||||
$this->add_lang('acp/common');
|
||||
|
||||
// Requires login first!
|
||||
if (empty($this->sid))
|
||||
{
|
||||
$this->fail('$this->sid is empty. Make sure you call login() before admin_login()');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getDriver()->manage()->deleteAllCookies();
|
||||
|
||||
$this->visit('adm/index.php?sid=' . $this->sid);
|
||||
$this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $this->getDriver()->getPageSource());
|
||||
|
||||
$this->find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username);
|
||||
$this->find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username);
|
||||
$this->find_element('cssSelector', 'input[name=login]')->click();
|
||||
$this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText());
|
||||
|
||||
$cookies = $this->getDriver()->manage()->getCookies();
|
||||
|
||||
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
||||
foreach ($cookies as $cookie)
|
||||
{
|
||||
if (substr($cookie['name'], -4) == '_sid')
|
||||
{
|
||||
$this->sid = $cookie['value'];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($this->sid);
|
||||
}
|
||||
|
||||
protected function add_lang($lang_file)
|
||||
{
|
||||
if (is_array($lang_file))
|
||||
{
|
||||
foreach ($lang_file as $file)
|
||||
{
|
||||
$this->add_lang($file);
|
||||
}
|
||||
}
|
||||
|
||||
$lang_path = __DIR__ . "/../../phpBB/language/en/$lang_file.php";
|
||||
|
||||
$lang = array();
|
||||
|
||||
if (file_exists($lang_path))
|
||||
{
|
||||
include($lang_path);
|
||||
}
|
||||
|
||||
$this->lang = array_merge($this->lang, $lang);
|
||||
}
|
||||
|
||||
protected function add_lang_ext($ext_name, $lang_file)
|
||||
{
|
||||
if (is_array($lang_file))
|
||||
{
|
||||
foreach ($lang_file as $file)
|
||||
{
|
||||
$this->add_lang_ext($ext_name, $file);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$lang_path = __DIR__ . "/../../phpBB/ext/{$ext_name}/language/en/$lang_file.php";
|
||||
|
||||
$lang = array();
|
||||
|
||||
if (file_exists($lang_path))
|
||||
{
|
||||
include($lang_path);
|
||||
}
|
||||
|
||||
$this->lang = array_merge($this->lang, $lang);
|
||||
}
|
||||
|
||||
protected function lang()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$key = $args[0];
|
||||
|
||||
if (empty($this->lang[$key]))
|
||||
{
|
||||
throw new RuntimeException('Language key "' . $key . '" could not be found.');
|
||||
}
|
||||
|
||||
$args[0] = $this->lang[$key];
|
||||
|
||||
return call_user_func_array('sprintf', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* assertContains for language strings
|
||||
*
|
||||
* @param string $needle Search string
|
||||
* @param string $haystack Search this
|
||||
* @param string $message Optional failure message
|
||||
*/
|
||||
public function assertContainsLang($needle, $haystack, $message = null)
|
||||
{
|
||||
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* assertNotContains for language strings
|
||||
*
|
||||
* @param string $needle Search string
|
||||
* @param string $haystack Search this
|
||||
* @param string $message Optional failure message
|
||||
*/
|
||||
public function assertNotContainsLang($needle, $haystack, $message = null)
|
||||
{
|
||||
$this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
||||
}
|
||||
|
||||
protected function login($username = 'admin')
|
||||
{
|
||||
$this->add_lang('ucp');
|
||||
|
||||
$this->getDriver()->manage()->deleteAllCookies();
|
||||
|
||||
$this->visit('ucp.php');
|
||||
$this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $this->getDriver()->getPageSource());
|
||||
|
||||
$this->getDriver()->manage()->deleteAllCookies();
|
||||
|
||||
$this->find_element('cssSelector', 'input[name=username]')->sendKeys($username);
|
||||
$this->find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username);
|
||||
$this->find_element('cssSelector', 'input[name=login]')->click();
|
||||
$this->assertNotContains($this->lang('LOGIN'), $this->find_element('className', 'navbar')->getText());
|
||||
|
||||
$cookies = $this->getDriver()->manage()->getCookies();
|
||||
|
||||
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
||||
foreach ($cookies as $cookie)
|
||||
{
|
||||
if (substr($cookie['name'], -4) == '_sid')
|
||||
{
|
||||
$this->sid = $cookie['value'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($this->sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take screenshot. Can be used for debug purposes.
|
||||
*
|
||||
* @throws Exception When screenshot can't be created
|
||||
*/
|
||||
public function take_screenshot()
|
||||
{
|
||||
// Change the Path to your own settings
|
||||
$screenshot = time() . ".png";
|
||||
|
||||
$this->getDriver()->takeScreenshot($screenshot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for AJAX. Should be called after an AJAX action is made.
|
||||
*
|
||||
* @param string $framework javascript frameworks jquery|prototype|dojo
|
||||
* @throws \Facebook\WebDriver\Exception\NoSuchElementException
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function waitForAjax($framework = 'jquery')
|
||||
{
|
||||
switch ($framework)
|
||||
{
|
||||
case 'jquery':
|
||||
$code = 'return jQuery.active;';
|
||||
break;
|
||||
case 'prototype':
|
||||
$code = 'return Ajax.activeRequestCount;';
|
||||
break;
|
||||
case 'dojo':
|
||||
$code = 'return dojo.io.XMLHTTPTransport.inFlight.length;';
|
||||
break;
|
||||
default:
|
||||
throw new \RuntimeException('Unsupported framework');
|
||||
break;
|
||||
}
|
||||
// wait for at most 30s, retry every 2000ms (2s)
|
||||
$driver = $this->getDriver();
|
||||
$driver->wait(30, 2000)->until(
|
||||
function () use ($driver, $code) {
|
||||
return !$driver->executeScript($code);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group ui
|
||||
*/
|
||||
class ui_permission_roles_test extends phpbb_ui_test_case
|
||||
{
|
||||
|
||||
public function test_permission_roles()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang('acp/permissions');
|
||||
$this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid);
|
||||
|
||||
// Select forums
|
||||
$elements = $this->find_element('cssSelector', 'select#forum')
|
||||
->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option'));
|
||||
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
$element->click();
|
||||
}
|
||||
$this->find_element('cssSelector', 'form#select_victim')
|
||||
->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]'))
|
||||
->click();
|
||||
|
||||
// Select administrators and guests
|
||||
$groups_form = $this->find_element('cssSelector', 'form#groups');
|
||||
$elements = $groups_form
|
||||
->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select'))
|
||||
->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option'));
|
||||
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
if ($element->getText() === 'Administrators' || $element->getText() === 'Guests')
|
||||
{
|
||||
$element->click();
|
||||
}
|
||||
}
|
||||
$groups_form->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[name=submit_edit_options]'))->click();
|
||||
|
||||
$first_fieldset = $this->find_element('cssSelector', '#perm11');
|
||||
$this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display'));
|
||||
$first_fieldset
|
||||
->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))
|
||||
->click();
|
||||
$this->assertEquals('block', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display'));
|
||||
$lis = $first_fieldset
|
||||
->findElements(\Facebook\WebDriver\WebDriverBy::cssSelector('ul > li'));
|
||||
|
||||
foreach ($lis as $li)
|
||||
{
|
||||
if ($li->getAttribute('data-id') == 18)
|
||||
{
|
||||
$li->click();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display'));
|
||||
$this->assertEquals(18, $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value'));
|
||||
$this->assertEquals($this->lang('ROLE_FORUM_LIMITED'), $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText());
|
||||
|
||||
// Check that admin settings didn't get changed
|
||||
$second_fieldset = $this->find_element('cssSelector', '#perm10');
|
||||
$this->assertEquals('none', $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display'));
|
||||
// Full access = 14
|
||||
$this->assertEquals(14, $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value'));
|
||||
$this->assertEquals($this->lang('ROLE_FORUM_FULL'), $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText());
|
||||
|
||||
// Check that category settings were not modified
|
||||
$category_fieldset = $this->find_element('cssSelector', '#perm00');
|
||||
$this->assertEquals('none', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display'));
|
||||
// No settings
|
||||
$this->assertEquals('', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value'));
|
||||
$this->assertEquals($this->lang('NO_ROLE_ASSIGNED'), $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText());
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group ui
|
||||
*/
|
||||
class quick_links_test extends phpbb_ui_test_case
|
||||
{
|
||||
public function test_quick_links()
|
||||
{
|
||||
$this->visit('index.php');
|
||||
$this->assertEmpty($this->find_element('className', 'dropdown')->getText());
|
||||
$this->find_element('className', 'dropdown-toggle')->click();
|
||||
$this->assertNotNull($this->find_element('className', 'dropdown')->getText());
|
||||
}
|
||||
}
|
@ -14,14 +14,10 @@
|
||||
<directory suffix="_test.php">../tests</directory>
|
||||
<exclude>../tests/functional</exclude>
|
||||
<exclude>../tests/lint_test.php</exclude>
|
||||
<exclude>../tests/ui</exclude>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB Functional Tests">
|
||||
<directory suffix="_test.php">../tests/functional</directory>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB UI Tests">
|
||||
<directory suffix="_test.php">../tests/ui</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
|
@ -14,14 +14,10 @@
|
||||
<directory suffix="_test.php">../tests</directory>
|
||||
<exclude>../tests/functional</exclude>
|
||||
<exclude>../tests/lint_test.php</exclude>
|
||||
<exclude>../tests/ui</exclude>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB Functional Tests">
|
||||
<directory suffix="_test.php">../tests/functional</directory>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB UI Tests">
|
||||
<directory suffix="_test.php">../tests/ui</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
|
@ -14,14 +14,10 @@
|
||||
<directory suffix="_test.php">../tests</directory>
|
||||
<exclude>../tests/functional</exclude>
|
||||
<exclude>../tests/lint_test.php</exclude>
|
||||
<exclude>../tests/ui</exclude>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB Functional Tests">
|
||||
<directory suffix="_test.php">../tests/functional</directory>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB UI Tests">
|
||||
<directory suffix="_test.php">../tests/ui</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
|
@ -14,14 +14,10 @@
|
||||
<directory suffix="_test.php">../tests</directory>
|
||||
<exclude>../tests/functional</exclude>
|
||||
<exclude>../tests/lint_test.php</exclude>
|
||||
<exclude>../tests/ui</exclude>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB Functional Tests">
|
||||
<directory suffix="_test.php">../tests/functional</directory>
|
||||
</testsuite>
|
||||
<testsuite name="phpBB UI Tests">
|
||||
<directory suffix="_test.php">../tests/ui</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
|
Loading…
x
Reference in New Issue
Block a user