diff options
author | Maat <maat-pub@mageia.biz> | 2020-05-09 01:15:08 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2020-05-09 01:15:08 +0200 |
commit | 6985226b17e8a0ef0a720bf1d12fe0c216e13dab (patch) | |
tree | 116d2565ac02c40abe0548863c6badf8ec3e1d1e /tests/test_framework/phpbb_ui_test_case.php | |
parent | 8ea437e30605e0f66b5220bf904a61d7c1d11ddd (diff) | |
parent | 8d00784dfe2c8bcb10843ff70b4cfa998d703285 (diff) | |
download | forums-master.tar forums-master.tar.gz forums-master.tar.bz2 forums-master.tar.xz forums-master.zip |
Diffstat (limited to 'tests/test_framework/phpbb_ui_test_case.php')
-rw-r--r-- | tests/test_framework/phpbb_ui_test_case.php | 96 |
1 files changed, 84 insertions, 12 deletions
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 48e510abe3..243db39d69 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -53,15 +53,10 @@ class phpbb_ui_test_case extends phpbb_test_case { parent::setUpBeforeClass(); - if (version_compare(PHP_VERSION, '5.3.19', '<')) - { - self::markTestSkipped('UI test case requires at least PHP 5.3.19.'); - } - else if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver')) + if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver')) { self::markTestSkipped( - 'Could not find RemoteWebDriver class. ' . - 'Run "php ../composer.phar install" from the tests folder.' + 'Could not find RemoteWebDriver class.' ); } @@ -108,7 +103,7 @@ class phpbb_ui_test_case extends phpbb_test_case return array(); } - public function setUp() + public function setUp(): void { if (!self::$install_success) { @@ -140,7 +135,7 @@ class phpbb_ui_test_case extends phpbb_test_case } } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); @@ -344,9 +339,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 @@ -371,6 +366,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) @@ -402,7 +473,8 @@ class phpbb_ui_test_case extends phpbb_test_case $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new \phpbb\db\tools($db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db); $container = new phpbb_mock_container_builder(); $migrator = new \phpbb\db\migrator( |