From 77f8bb48fedf0e1afad3a98655aed94c21ae863c Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 00:04:15 +0200 Subject: [PATCH 01/20] [ticket/12962] Add initial class for ui_testing PHPBB3-12962 --- tests/test_framework/phpbb_ui_test_case.php | 190 ++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 tests/test_framework/phpbb_ui_test_case.php diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php new file mode 100644 index 0000000000..d8ef98ba7c --- /dev/null +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -0,0 +1,190 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/vendor/facebook/webdriver/lib/__init__.php'; +require_once __DIR__ . '/phpbb_test_case_helpers.php'; + +require_once __DIR__ . '/../../phpBB/includes/functions_install.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 public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + 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.'); + } + + if (!self::$webDriver) + { + $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox'); + self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + } + + if (!self::$already_installed) + { + self::install_board(); + self::$already_installed = true; + } + } + + static public function visit($path) + { + self::$webDriver->get(self::$root_url . $path); + } + + static protected function recreate_database($config) + { + $db_conn_mgr = new phpbb_database_test_connection_manager($config); + $db_conn_mgr->recreate_db(); + } + + static public function find_element($type, $value) + { + return self::$webDriver->findElement(WebDriverBy::$type($value)); + } + + static public function submit($type = 'id', $value = 'submit') + { + $element = self::find_element($type, $value); + $element->click(); + } + + static public function install_board() + { + global $phpbb_root_path, $phpEx; + + 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); + } + } + + $parseURL = parse_url(self::$config['phpbb_functional_url']); + + self::visit('install/index.php?mode=install'); + self::assertContains('Welcome to Installation', self::find_element('id', 'main')->getText()); + + // install/index.php?mode=install&sub=requirements + self::submit(); + self::assertContains('Installation compatibility', self::find_element('id', 'main')->getText()); + + // install/index.php?mode=install&sub=database + self::submit(); + self::assertContains('Database configuration', self::find_element('id', 'main')->getText()); + + self::find_element('id','dbms')->sendKeys(str_replace('phpbb\db\driver\\', '', self::$config['dbms'])); + self::find_element('id','dbhost')->sendKeys(self::$config['dbhost']); + self::find_element('id','dbport')->sendKeys(self::$config['dbport']); + self::find_element('id','dbname')->sendKeys(self::$config['dbname']); + self::find_element('id','dbuser')->sendKeys(self::$config['dbuser']); + self::find_element('id','dbpasswd')->sendKeys(self::$config['dbpasswd']); + + // Need to clear default phpbb_ prefix + self::find_element('id','table_prefix')->clear(); + self::find_element('id','table_prefix')->sendKeys(self::$config['table_prefix']); + + // install/index.php?mode=install&sub=database + self::submit(); + self::assertContains('Successful connection', self::find_element('id','main')->getText()); + + // install/index.php?mode=install&sub=administrator + self::submit(); + self::assertContains('Administrator configuration', self::find_element('id','main')->getText()); + + self::find_element('id','admin_name')->sendKeys('admin'); + self::find_element('id','admin_pass1')->sendKeys('adminadmin'); + self::find_element('id','admin_pass2')->sendKeys('adminadmin'); + self::find_element('id','board_email')->sendKeys('nobody@example.com'); + + // install/index.php?mode=install&sub=administrator + self::submit(); + self::assertContains('Tests passed', self::find_element('id','main')->getText()); + + // install/index.php?mode=install&sub=config_file + self::submit(); + + // Installer has created a config.php file, we will overwrite it with a + // config file of our own in order to get the DEBUG constants defined + $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true); + $config_created = file_put_contents($config_file, $config_php_data) !== false; + if (!$config_created) + { + self::markTestSkipped("Could not write $config_file file."); + } + + if (strpos(self::find_element('id','main')->getText(), 'The configuration file has been written') === false) + { + self::submit('id', 'dldone'); + } + self::assertContains('The configuration file has been written', self::find_element('id','main')->getText()); + + // install/index.php?mode=install&sub=advanced + self::submit(); + self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', self::find_element('id','main')->getText()); + + self::find_element('id','smtp_delivery')->sendKeys('1'); + self::find_element('id','smtp_host')->sendKeys('nxdomain.phpbb.com'); + self::find_element('id','smtp_user')->sendKeys('nxuser'); + self::find_element('id','smtp_pass')->sendKeys('nxpass'); + self::find_element('id','server_protocol')->sendKeys($parseURL['scheme'] . '://'); + self::find_element('id','server_name')->sendKeys('localhost'); + self::find_element('id','server_port')->sendKeys(isset($parseURL['port']) ? $parseURL['port'] : 80); + self::find_element('id','script_path')->sendKeys($parseURL['path']); + + // install/index.php?mode=install&sub=create_table + self::submit(); + self::assertContains('The database tables used by phpBB', self::find_element('id','main')->getText()); + self::assertContains('have been created and populated with some initial data.', self::find_element('id','main')->getText()); + + // install/index.php?mode=install&sub=final + self::submit(); + self::assertContains('You have successfully installed', self::find_element('id', 'main')->getText()); + + copy($config_file, $config_file_test); + } +} From f21ef60175ce5a5744231410c18f1c4a701a17ab Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 00:44:00 +0200 Subject: [PATCH 02/20] [ticket/12962] Add quick-links JS test PHPBB3-12962 --- tests/bootstrap.php | 71 +++++++++++---------- tests/test_framework/phpbb_ui_test_case.php | 4 +- tests/ui/quick_links_test.php | 27 ++++++++ 3 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 tests/ui/quick_links_test.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 40c6ef7dfa..f27fa31cea 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,35 +1,36 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -define('IN_PHPBB', true); -$phpbb_root_path = 'phpBB/'; -$phpEx = 'php'; -require_once $phpbb_root_path . 'includes/startup.php'; - -$table_prefix = 'phpbb_'; -require_once $phpbb_root_path . 'includes/constants.php'; -require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; -require_once($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); -$phpbb_class_loader_mock->register(); -$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); -$phpbb_class_loader->register(); - -require_once 'test_framework/phpbb_test_case_helpers.php'; -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'; + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +define('IN_PHPBB', true); +$phpbb_root_path = 'phpBB/'; +$phpEx = 'php'; +require_once $phpbb_root_path . 'includes/startup.php'; + +$table_prefix = 'phpbb_'; +require_once $phpbb_root_path . 'includes/constants.php'; +require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; +require_once($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); +$phpbb_class_loader_mock->register(); +$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php"); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); +$phpbb_class_loader->register(); + +require_once 'test_framework/phpbb_test_case_helpers.php'; +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'; diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index d8ef98ba7c..271a102299 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -10,9 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../phpBB/vendor/facebook/webdriver/lib/__init__.php'; -require_once __DIR__ . '/phpbb_test_case_helpers.php'; - +require_once __DIR__ . '/../../phpBB/vendor/facebook/webdriver/lib/__init__.php'; require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; class phpbb_ui_test_case extends phpbb_test_case diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php new file mode 100644 index 0000000000..5bddb44a8b --- /dev/null +++ b/tests/ui/quick_links_test.php @@ -0,0 +1,27 @@ + +* @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(self::find_element('className', 'dropdown')->getText()); + self::find_element('className', 'dropdown-toggle')->click(); + $this->assertNotNull(self::find_element('className', 'dropdown')->getText()); + } +} From c0d3cf6a279645c5bb9aac334c241302a21f557a Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 00:48:31 +0200 Subject: [PATCH 03/20] [ticket/12962] Add UI tests to phpunit.xml.dist PHPBB3-12962 --- phpunit.xml.dist | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3475742288..a497717107 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,6 +16,7 @@ ./tests ./tests/functional ./tests/lint_test.php + ./tests/ui ./tests/functional @@ -23,6 +24,9 @@ ./tests/lint_test.php + + ./tests/ui + From 6de352f7daa5d59c478ac31168d1a0220f7616a8 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 00:53:01 +0200 Subject: [PATCH 04/20] [ticket/12962] Run UI tests on Travis-mysql PHPBB3-12962 --- .travis.yml | 1 + travis/phpunit-mysql-travis.xml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index cbba07b16d..b2514d1d57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ install: before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION + - phantomjs --webdriver=8910 script: - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 21122ccaeb..d0d3e3c0c0 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -16,10 +16,14 @@ ../tests ../tests/functional ../tests/lint_test.php + ../tests/ui ../tests/functional + + ../tests/ui + From 8d0933ca4bf2724f7a67471edb6b5efe2cdc02e1 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 12:10:59 +0200 Subject: [PATCH 05/20] [ticket/12962] Add setup-phantomjs-server.sh PHPBB3-12962 --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2514d1d57..ebe2dfe8f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,8 @@ install: before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION - - phantomjs --webdriver=8910 + - pidof phantomjs || nohup phantomjs --webserver=8910 > /dev/null + - sleep 3 script: - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION @@ -43,4 +44,4 @@ script: - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION ./ - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3.3' -a '$DB' = 'mysqli' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" - + - kill -9 `pidof phantomjs` From c371e86fa1a640661a47b1d4871f4ea7730f727f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 12:55:21 +0200 Subject: [PATCH 06/20] [ticket/12962] Mark test skipped when phantom server not running PHPBB3-12962 --- .travis.yml | 2 +- tests/test_framework/phpbb_ui_test_case.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ebe2dfe8f0..1bd16fdef7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ install: before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION - - pidof phantomjs || nohup phantomjs --webserver=8910 > /dev/null + - pidof phantomjs || nohup phantomjs --webdriver=8910 > /dev/null - sleep 3 script: diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 271a102299..9671cc5da4 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -47,8 +47,12 @@ class phpbb_ui_test_case extends phpbb_test_case if (!self::$webDriver) { - $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox'); - self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + try { + $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox'); + self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + } catch (WebDriverCurlException $e) { + self::markTestSkipped('PhantomJS webserver is not running.'); + } } if (!self::$already_installed) From 039b466bd036d1193bc638a37458bb5b85541dd5 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 13:14:47 +0200 Subject: [PATCH 07/20] [ticket/12962] Start phantomjs on travis in background PHPBB3-12962 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1bd16fdef7..32f9d999a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,8 +34,7 @@ install: before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION - - pidof phantomjs || nohup phantomjs --webdriver=8910 > /dev/null - - sleep 3 + - phantomjs --webdriver=8910 & script: - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION From d1935b0b0bd2df9dab6e8eefdfedbec8653270fb Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 13:35:49 +0200 Subject: [PATCH 08/20] [ticket/12962] Dump server output to /dev/null PHPBB3-12962 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32f9d999a0..b44a3deedb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ install: before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION - - phantomjs --webdriver=8910 & + - phantomjs --webdriver=8910 > /dev/null & script: - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION From 20dfb23dd437c15999f8886bf17096606525bb27 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 13:58:57 +0200 Subject: [PATCH 09/20] [ticket/12962] Force language=en for UI tests installation PHPBB3-12962 --- tests/test_framework/phpbb_ui_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 9671cc5da4..7787f4ee68 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -108,7 +108,7 @@ class phpbb_ui_test_case extends phpbb_test_case $parseURL = parse_url(self::$config['phpbb_functional_url']); - self::visit('install/index.php?mode=install'); + self::visit('install/index.php?mode=install&language=en'); self::assertContains('Welcome to Installation', self::find_element('id', 'main')->getText()); // install/index.php?mode=install&sub=requirements From a2627e8790733f59339cea8e451d4b2183986288 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 14:30:58 +0200 Subject: [PATCH 10/20] [ticket/12962] Run tests for all databases on Travis PHPBB3-12962 --- travis/phpunit-mariadb-travis.xml | 4 ++++ travis/phpunit-mysqli-travis.xml | 4 ++++ travis/phpunit-postgres-travis.xml | 4 ++++ travis/phpunit-sqlite3-travis.xml | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/travis/phpunit-mariadb-travis.xml b/travis/phpunit-mariadb-travis.xml index aa245a8224..53a206b9b0 100644 --- a/travis/phpunit-mariadb-travis.xml +++ b/travis/phpunit-mariadb-travis.xml @@ -16,10 +16,14 @@ ../tests ../tests/functional ../tests/lint_test.php + ../tests/ui ../tests/functional + + ../tests/ui + diff --git a/travis/phpunit-mysqli-travis.xml b/travis/phpunit-mysqli-travis.xml index 60c279d774..4c963895fc 100644 --- a/travis/phpunit-mysqli-travis.xml +++ b/travis/phpunit-mysqli-travis.xml @@ -16,6 +16,7 @@ ../tests ../tests/functional ../tests/lint_test.php + ../tests/ui ../tests/lint_test.php @@ -23,6 +24,9 @@ ../tests/functional + + ../tests/ui + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 956278e90c..fa497a1264 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -16,10 +16,14 @@ ../tests ../tests/functional ../tests/lint_test.php + ../tests/ui ../tests/functional + + ../tests/ui + diff --git a/travis/phpunit-sqlite3-travis.xml b/travis/phpunit-sqlite3-travis.xml index 72b8b8c8ca..5baab791e0 100644 --- a/travis/phpunit-sqlite3-travis.xml +++ b/travis/phpunit-sqlite3-travis.xml @@ -16,10 +16,14 @@ ../tests ../tests/functional ../tests/lint_test.php + ../tests/ui ../tests/functional + + ../tests/ui + From a1dff65cd1872fd239c0e78949a5924ee6784a34 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 14:55:44 +0200 Subject: [PATCH 11/20] [ticket/12962] Fix whitespace characters PHPBB3-12962 --- tests/test_framework/phpbb_ui_test_case.php | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 7787f4ee68..451aad7e60 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -18,17 +18,17 @@ 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; + /** + * @var \RemoteWebDriver + */ + static protected $webDriver; - static protected $config; - static protected $root_url; - static protected $already_installed = false; + static protected $config; + static protected $root_url; + static protected $already_installed = false; static public function setUpBeforeClass() - { + { parent::setUpBeforeClass(); self::$config = phpbb_test_case_helpers::get_test_config(); @@ -60,14 +60,14 @@ class phpbb_ui_test_case extends phpbb_test_case self::install_board(); self::$already_installed = true; } - } + } - static public function visit($path) - { + static public function visit($path) + { self::$webDriver->get(self::$root_url . $path); - } + } - static protected function recreate_database($config) + static protected function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); $db_conn_mgr->recreate_db(); @@ -84,8 +84,8 @@ class phpbb_ui_test_case extends phpbb_test_case $element->click(); } - static public function install_board() - { + static public function install_board() + { global $phpbb_root_path, $phpEx; self::recreate_database(self::$config); @@ -188,5 +188,5 @@ class phpbb_ui_test_case extends phpbb_test_case self::assertContains('You have successfully installed', self::find_element('id', 'main')->getText()); copy($config_file, $config_file_test); - } + } } From 77d52982c8b8e0a6366b361ee0d2fe8cf588b5d7 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 21 Sep 2014 12:52:53 +0530 Subject: [PATCH 12/20] [ticket/12962] Add facebook/webdriver dependency Create a new composer.json for tests dir and add facebook/webdriver dependency PHPBB3-12962 --- .gitignore | 1 + tests/composer.json | 24 ++++++++ tests/composer.lock | 66 +++++++++++++++++++++ tests/test_framework/phpbb_ui_test_case.php | 2 +- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/composer.json create mode 100644 tests/composer.lock diff --git a/.gitignore b/.gitignore index de503c10ad..c327e7f58a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ /tests/phpbb_unit_tests.sqlite* /tests/test_config*.php /tests/tmp/* +/tests/vendor diff --git a/tests/composer.json b/tests/composer.json new file mode 100644 index 0000000000..d92c8eec0e --- /dev/null +++ b/tests/composer.json @@ -0,0 +1,24 @@ +{ + "name": "phpbb/phpbb", + "description": "phpBB Forum Software application", + "type": "project", + "keywords": ["phpbb", "forum"], + "homepage": "https://www.phpbb.com", + "license": "GPL-2.0", + "authors": [ + { + "name": "phpBB Limited", + "email": "operations@phpbb.com", + "homepage": "https://www.phpbb.com/go/authors" + } + ], + "support": { + "issues": "https://tracker.phpbb.com", + "forum": "https://www.phpbb.com/community/", + "wiki": "https://wiki.phpbb.com", + "irc": "irc://irc.freenode.org/phpbb" + }, + "require-dev": { + "facebook/webdriver": "dev-master" + } +} diff --git a/tests/composer.lock b/tests/composer.lock new file mode 100644 index 0000000000..32d90d43fc --- /dev/null +++ b/tests/composer.lock @@ -0,0 +1,66 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "2affca245bd4946ca7acdf46f100af3c", + "packages": [ + + ], + "packages-dev": [ + { + "name": "facebook/webdriver", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/facebook/php-webdriver.git", + "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/b6e002e5bf811a8edba393ce6872322c1b7cf796", + "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796", + "shasum": "" + }, + "require": { + "php": ">=5.3.19" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "2.*", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "http://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "A php client for WebDriver", + "homepage": "https://github.com/facebook/php-webdriver", + "keywords": [ + "facebook", + "php", + "selenium", + "webdriver" + ], + "time": "2014-08-05 02:55:46" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": { + "facebook/webdriver": 20 + }, + "platform": [ + + ], + "platform-dev": [ + + ] +} diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 451aad7e60..702b15d50a 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -10,7 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../phpBB/vendor/facebook/webdriver/lib/__init__.php'; +require_once __DIR__ . '/../vendor/facebook/webdriver/lib/__init__.php'; require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; class phpbb_ui_test_case extends phpbb_test_case From 7fa596a991add3e47c7e5a7033256073f1a50198 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 21 Sep 2014 13:25:32 +0530 Subject: [PATCH 13/20] [ticket/12962] Install test dependencies on travis PHPBB3-12962 --- travis/setup-phpbb-test.sh | 16 ++++++++++++++++ travis/setup-phpbb.sh | 5 +++++ 2 files changed, 21 insertions(+) create mode 100755 travis/setup-phpbb-test.sh diff --git a/travis/setup-phpbb-test.sh b/travis/setup-phpbb-test.sh new file mode 100755 index 0000000000..25743ff2b1 --- /dev/null +++ b/travis/setup-phpbb-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +cd tests +php ../composer.phar install --dev --no-interaction --prefer-source +cd .. diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index d829772196..e1b7a782c6 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -35,6 +35,11 @@ then travis/setup-webserver.sh fi +if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.4', '>=');"` == "1" ] +then + travis/setup-phpbb-test.sh +fi + cd phpBB php ../composer.phar install --dev --no-interaction --prefer-source cd .. From 29ffddee71e21751ce1e108dd486642caf2d75bf Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 21 Sep 2014 15:54:52 +0530 Subject: [PATCH 14/20] [ticket/12962] bootstrap functional and ui test when php >5.3.19 PHPBB3-12962 --- tests/bootstrap.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f27fa31cea..e3c7f31b8c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -32,5 +32,9 @@ require_once 'test_framework/phpbb_test_case_helpers.php'; 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 (version_compare(PHP_VERSION,'5.3.19',">=")) +{ + require_once 'test_framework/phpbb_functional_test_case.php'; + require_once 'test_framework/phpbb_ui_test_case.php'; +} From e78210dc96e9b2d0c6318a77406e60f30f37b50f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 25 Oct 2014 15:34:39 -0700 Subject: [PATCH 15/20] [ticket/12962] Load composer test dependencies for php >= 5.3.19 PHPBB3-12962 --- travis/setup-phpbb.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index e1b7a782c6..e91b6f3624 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -33,10 +33,6 @@ fi if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` == "1" ] then travis/setup-webserver.sh -fi - -if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.4', '>=');"` == "1" ] -then travis/setup-phpbb-test.sh fi From 1c88a2cb25a162d111681956edbc0343491ed7d9 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 25 Oct 2014 17:33:47 -0700 Subject: [PATCH 16/20] [ticket/12962] Fix Line Endings in bootstrap PHPBB3-12962 --- tests/bootstrap.php | 80 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e3c7f31b8c..6e5d0b2f39 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,40 +1,40 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -define('IN_PHPBB', true); -$phpbb_root_path = 'phpBB/'; -$phpEx = 'php'; -require_once $phpbb_root_path . 'includes/startup.php'; - -$table_prefix = 'phpbb_'; -require_once $phpbb_root_path . 'includes/constants.php'; -require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; -require_once($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); -$phpbb_class_loader_mock->register(); -$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); -$phpbb_class_loader->register(); - -require_once 'test_framework/phpbb_test_case_helpers.php'; -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'; - -if (version_compare(PHP_VERSION,'5.3.19',">=")) -{ - require_once 'test_framework/phpbb_functional_test_case.php'; - require_once 'test_framework/phpbb_ui_test_case.php'; -} + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +define('IN_PHPBB', true); +$phpbb_root_path = 'phpBB/'; +$phpEx = 'php'; +require_once $phpbb_root_path . 'includes/startup.php'; + +$table_prefix = 'phpbb_'; +require_once $phpbb_root_path . 'includes/constants.php'; +require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; +require_once($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); +$phpbb_class_loader_mock->register(); +$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php"); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); +$phpbb_class_loader->register(); + +require_once 'test_framework/phpbb_test_case_helpers.php'; +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'; + +if (version_compare(PHP_VERSION,'5.3.19',">=")) +{ + require_once 'test_framework/phpbb_functional_test_case.php'; + require_once 'test_framework/phpbb_ui_test_case.php'; +} From 98554475bee3d6fee17f24ef6c882f27b647668f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 26 Oct 2014 20:58:21 -0700 Subject: [PATCH 17/20] [ticket/12962] Clean up composer.json PHPBB3-12962 --- tests/composer.json | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/tests/composer.json b/tests/composer.json index d92c8eec0e..69512f30a6 100644 --- a/tests/composer.json +++ b/tests/composer.json @@ -1,23 +1,4 @@ { - "name": "phpbb/phpbb", - "description": "phpBB Forum Software application", - "type": "project", - "keywords": ["phpbb", "forum"], - "homepage": "https://www.phpbb.com", - "license": "GPL-2.0", - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "support": { - "issues": "https://tracker.phpbb.com", - "forum": "https://www.phpbb.com/community/", - "wiki": "https://wiki.phpbb.com", - "irc": "irc://irc.freenode.org/phpbb" - }, "require-dev": { "facebook/webdriver": "dev-master" } From c6cca9d0d258fdbe832bba5d40a6e044e90ff873 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 26 Oct 2014 21:30:31 -0700 Subject: [PATCH 18/20] [ticket/12962] Functional tests run for php <5.3.19 PHPBB3-12962 --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6e5d0b2f39..c635a3abf4 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -32,9 +32,9 @@ require_once 'test_framework/phpbb_test_case_helpers.php'; 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'; if (version_compare(PHP_VERSION,'5.3.19',">=")) { - require_once 'test_framework/phpbb_functional_test_case.php'; require_once 'test_framework/phpbb_ui_test_case.php'; } From cc82f95c8fd46c68dcd87334e37d3bfcd1d7c316 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 27 Oct 2014 08:13:41 -0700 Subject: [PATCH 19/20] [ticket/12962] Use phpVersion in phpunit.xml PHPBB3-12962 --- .travis.yml | 1 - phpunit.xml.dist | 3 ++- tests/bootstrap.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b44a3deedb..1eb7c56236 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,4 +43,3 @@ script: - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION ./ - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3.3' -a '$DB' = 'mysqli' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" - - kill -9 `pidof phantomjs` diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a497717107..bcc63d6fd9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -25,7 +25,8 @@ ./tests/lint_test.php - ./tests/ui + ./tests/ui diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c635a3abf4..65447eb95c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -34,7 +34,7 @@ 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'; -if (version_compare(PHP_VERSION,'5.3.19',">=")) +if (version_compare(PHP_VERSION,'5.3.19', ">=")) { require_once 'test_framework/phpbb_ui_test_case.php'; } From 505ee586ff17a6e1a960cfee28c8c395da040629 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 27 Oct 2014 18:36:33 -0400 Subject: [PATCH 20/20] [ticket/12962] Rename setup-phpbb-test PHPBB3-12962 --- .travis.yml | 1 + .../{setup-phpbb-test.sh => install-phpbb-test-dependencies.sh} | 0 travis/setup-phpbb.sh | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) rename travis/{setup-phpbb-test.sh => install-phpbb-test-dependencies.sh} (100%) diff --git a/.travis.yml b/.travis.yml index 1eb7c56236..2e0b68c3de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,3 +43,4 @@ script: - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION ./ - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3.3' -a '$DB' = 'mysqli' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" + diff --git a/travis/setup-phpbb-test.sh b/travis/install-phpbb-test-dependencies.sh similarity index 100% rename from travis/setup-phpbb-test.sh rename to travis/install-phpbb-test-dependencies.sh diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index e91b6f3624..205f23b876 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -33,7 +33,7 @@ fi if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` == "1" ] then travis/setup-webserver.sh - travis/setup-phpbb-test.sh + travis/install-phpbb-test-dependencies.sh fi cd phpBB