diff options
author | rxu <rxu@mail.ru> | 2018-07-28 16:32:24 +0700 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-05-09 18:46:50 +0200 |
commit | ab0dae600335eb66a31c951e27954accac208296 (patch) | |
tree | b5e733677a44781cdc46c0b2234d6140ed287d69 /tests/test_framework | |
parent | 64b053c9970494521f610bb07c101a7b81ec618e (diff) | |
download | forums-ab0dae600335eb66a31c951e27954accac208296.tar forums-ab0dae600335eb66a31c951e27954accac208296.tar.gz forums-ab0dae600335eb66a31c951e27954accac208296.tar.bz2 forums-ab0dae600335eb66a31c951e27954accac208296.tar.xz forums-ab0dae600335eb66a31c951e27954accac208296.zip |
[ticket/15725] Fix installing ext in tests for master branch
PHPBB3-15725
Diffstat (limited to 'tests/test_framework')
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 70 | ||||
-rw-r--r-- | tests/test_framework/phpbb_ui_test_case.php | 80 |
2 files changed, 146 insertions, 4 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9351ab3f4a..844fc4619d 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -424,9 +424,9 @@ 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('.submit-buttons')->count()); + $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count()); - $form = $crawler->selectButton('Enable')->form(); + $form = $crawler->selectButton('confirm')->form(); $crawler = self::submit($form); $this->add_lang('acp/extensions'); @@ -446,6 +446,72 @@ class phpbb_functional_test_case extends phpbb_test_case $this->logout(); } + public function disable_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=disable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); + $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count()); + + $form = $crawler->selectButton('confirm')->form(); + $crawler = self::submit($form); + $this->add_lang('acp/extensions'); + + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + + // Wait for extension to be fully enabled + while (count($meta_refresh)) + { + preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); + $url = $match[1]; + $crawler = self::request('POST', $url); + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + } + + $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('div.successbox')->text()); + + $this->logout(); + } + + public function delete_ext_data($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=delete_data_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); + $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count()); + + $form = $crawler->selectButton('confirm')->form(); + $crawler = self::submit($form); + $this->add_lang('acp/extensions'); + + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + + // Wait for extension to be fully enabled + while (count($meta_refresh)) + { + preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); + $url = $match[1]; + $crawler = self::request('POST', $url); + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + } + + $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('div.successbox')->text()); + + $this->logout(); + } + + public function uninstall_ext($extension) + { + $this->disable_ext($extension); + $this->delete_ext_data($extension); + } + static private function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 7b950a7d5d..09b0927966 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -322,9 +322,9 @@ class phpbb_ui_test_case extends phpbb_test_case $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', '.submit-buttons'))); + $this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset div input.button2'))); - $this->find_element('cssSelector', "input[value='Enable']")->submit(); + $this->find_element('cssSelector', "input[value='Yes']")->submit(); $this->add_lang('acp/extensions'); try @@ -349,6 +349,82 @@ class phpbb_ui_test_case extends phpbb_test_case $this->logout(); } + public function disable_ext($extension) + { + $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 div input.button2'))); + + $this->find_element('cssSelector', "input[value='Yes']")->submit(); + $this->add_lang('acp/extensions'); + + 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->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 div input.button2'))); + + $this->find_element('cssSelector', "input[value='Yes']")->submit(); + $this->add_lang('acp/extensions'); + + 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) |