From d63b5a1315ecf819a412db382c1adcfa39fd9813 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 14:26:32 +0100 Subject: [ticket/14462] Fix installation in tests PHPBB3-14462 --- tests/test_framework/phpbb_functional_test_case.php | 18 ++++++++++++------ tests/test_framework/phpbb_ui_test_case.php | 21 +++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 34fbcec0e2..5083e7bdfa 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -20,6 +20,7 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $client; static protected $cookieJar; static protected $root_url; + static protected $install_success = false; protected $cache = null; protected $db = null; @@ -78,6 +79,11 @@ class phpbb_functional_test_case extends phpbb_test_case { parent::setUp(); + if (!self::$install_success) + { + $this->fail('Installing phpBB has failed.'); + } + $this->bootstrap(); self::$cookieJar = new CookieJar; @@ -360,17 +366,17 @@ class phpbb_functional_test_case extends phpbb_test_case $iohandler->set_input('script_path', $parseURL['path']); $iohandler->set_input('submit_server', 'submit'); - do - { - $installer->run(); - } - while (file_exists($phpbb_root_path . 'store/install_config.php')); + $installer->run(); copy($config_file, $config_file_test); - if (file_exists($phpbb_root_path . 'cache/install_lock')) + self::$install_success = true; + + if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) { + self::$install_success = false; unlink($phpbb_root_path . 'cache/install_lock'); + unlink($phpbb_root_path . 'store/install_config.php'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e118801972..59f3bdf242 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -26,6 +26,7 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $config; static protected $root_url; static protected $already_installed = false; + static protected $install_success = false; static public function setUpBeforeClass() { @@ -74,6 +75,14 @@ class phpbb_ui_test_case extends phpbb_test_case } } + public function setUp() + { + if (!self::$install_success) + { + $this->fail('Installing phpBB has failed.'); + } + } + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); @@ -194,17 +203,17 @@ class phpbb_ui_test_case extends phpbb_test_case $iohandler->set_input('script_path', $parseURL['path']); $iohandler->set_input('submit_server', 'submit'); - do - { - $installer->run(); - } - while (file_exists($phpbb_root_path . 'store/install_config.php')); + $installer->run(); copy($config_file, $config_file_test); - if (file_exists($phpbb_root_path . 'cache/install_lock')) + self::$install_success = true; + + if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) { + self::$install_success = false; unlink($phpbb_root_path . 'cache/install_lock'); + unlink($phpbb_root_path . 'store/install_config.php'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; -- cgit v1.2.1 From 90710ffe9818fb45d177db4a8b07c70a43972776 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Feb 2016 14:08:47 +0100 Subject: [ticket/14462] Set instance of db driver for database access using global PHPBB3-14462 --- tests/test_framework/phpbb_ui_test_case.php | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 59f3bdf242..14e84b019d 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -27,6 +27,7 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $root_url; static protected $already_installed = false; static protected $install_success = false; + static protected $db; static public function setUpBeforeClass() { @@ -83,6 +84,17 @@ class phpbb_ui_test_case extends phpbb_test_case } } + protected function tearDown() + { + parent::tearDown(); + + if (self::$db instanceof \phpbb\db\driver\driver_interface) + { + // Close the database connections again this test + self::$db->sql_close(); + } + } + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); @@ -107,10 +119,12 @@ class phpbb_ui_test_case extends phpbb_test_case static public function install_board() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $db; self::recreate_database(self::$config); + $db = self::get_db(); + $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"; @@ -220,4 +234,19 @@ class phpbb_ui_test_case extends phpbb_test_case $phpbb_container->reset(); unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); } + + static protected function get_db() + { + global $phpbb_root_path, $phpEx; + // so we don't reopen an open connection + if (!(self::$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']); + self::$db = $db; + } + return self::$db; + } } -- cgit v1.2.1 From 7c0fb563ec995d0d1fcb24d885a7d9d18838ed9c Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 15:38:34 +0100 Subject: [ticket/14462] Fix CS and typo PHPBB3-14462 --- tests/test_framework/phpbb_ui_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 14e84b019d..9cbac0ce47 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -94,7 +94,7 @@ class phpbb_ui_test_case extends phpbb_test_case self::$db->sql_close(); } } - + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); -- cgit v1.2.1 From 97d128a7e4702b5a28b223b177a0e182e3b79080 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 15:53:36 +0100 Subject: [ticket/14462] Fix tests PHPBB3-14462 --- tests/test_framework/phpbb_functional_test_case.php | 10 +++++++--- tests/test_framework/phpbb_ui_test_case.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 5083e7bdfa..53519617b3 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -372,11 +372,15 @@ class phpbb_functional_test_case extends phpbb_test_case self::$install_success = true; - if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) + if (file_exists($phpbb_root_path . 'store/install_config.php')) { self::$install_success = false; - unlink($phpbb_root_path . 'cache/install_lock'); - unlink($phpbb_root_path . 'store/install_config.php'); + @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, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 9cbac0ce47..3aec2a19f4 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -223,11 +223,15 @@ class phpbb_ui_test_case extends phpbb_test_case self::$install_success = true; - if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) + if (file_exists($phpbb_root_path . 'store/install_config.php')) { self::$install_success = false; - unlink($phpbb_root_path . 'cache/install_lock'); - unlink($phpbb_root_path . 'store/install_config.php'); + @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, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; -- cgit v1.2.1