From 997028a0ecf1df761363b061acf6ae220dd3479f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 01:17:51 +0200 Subject: [ticket/12483] Allow to setup extensions before database and functional tests PHPBB3-12483 --- .../test_framework/phpbb_functional_test_case.php | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 182ffaaaf7..110c84927c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -64,6 +64,14 @@ class phpbb_functional_test_case extends phpbb_test_case } } + /** + * @return array List of extensions that should be set up + */ + static protected function setup_extensions() + { + return array(); + } + public function setUp() { parent::setUp(); @@ -81,6 +89,23 @@ class phpbb_functional_test_case extends phpbb_test_case $this->lang = array(); $this->add_lang('common'); $this->purge_cache(); + + $db = $this->get_db(); + + foreach (static::setup_extensions() as $extension) + { + $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); + } + } } /** @@ -358,6 +383,23 @@ class phpbb_functional_test_case extends phpbb_test_case copy($config_file, $config_file_test); } + public function install_ext($extension) + { + $this->login(); + $this->admin_login(); + + $ext_path = str_replace('/', '%2F', $extension); + + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); + $this->assertGreaterThan(0, $crawler->filter('div.errorbox')->count()); + + $form = $crawler->selectButton('Enable')->form(); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('div.successbox')->count()); + + $this->logout(); + } + static private function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); @@ -714,6 +756,30 @@ class phpbb_functional_test_case extends phpbb_test_case $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(); -- cgit v1.2.1 From 7b0b6a99c031bdcbf2bfdf0d7ebbf1784ecbbd59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 4 May 2014 23:15:56 +0200 Subject: [ticket/12483] Close database connection when tearDown() is called Similar to phpbb_database_test_case::tearDown() PHPBB3-12483 --- tests/test_framework/phpbb_functional_test_case.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 110c84927c..36d577aed7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -108,6 +108,17 @@ class phpbb_functional_test_case extends phpbb_test_case } } + protected function tearDown() + { + parent::tearDown(); + + if ($this->db instanceof \phpbb\db\driver\driver_interface) + { + // Close the database connections again this test + $this->db->sql_close(); + } + } + /** * Perform a request to page * -- cgit v1.2.1 From 916db1a0b156a953b1917d74924f750864df4701 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Jun 2014 20:04:03 +0200 Subject: [ticket/12483] Fix selectors for installing extensions in functional tests PHPBB3-12483 --- tests/test_framework/phpbb_functional_test_case.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 36d577aed7..e4504a5f8d 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -402,11 +402,12 @@ class phpbb_functional_test_case extends phpbb_test_case $ext_path = str_replace('/', '%2F', $extension); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); - $this->assertGreaterThan(0, $crawler->filter('div.errorbox')->count()); + $this->assertGreaterThan(0, $crawler->filter('.submit-buttons')->count()); $form = $crawler->selectButton('Enable')->form(); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('div.successbox')->count()); + $this->add_lang('acp/extensions'); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); $this->logout(); } -- cgit v1.2.1