diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cache/cache_memory.php | 2 | ||||
-rw-r--r-- | tests/console/user/base.php | 3 | ||||
-rw-r--r-- | tests/functional/acp_profile_field_test.php | 15 | ||||
-rw-r--r-- | tests/functions/user_delete_test.php | 4 | ||||
-rw-r--r-- | tests/functions_user/delete_user_test.php | 3 | ||||
-rw-r--r-- | tests/request/type_cast_helper_test.php | 10 | ||||
-rw-r--r-- | tests/security/redirect_test.php | 2 | ||||
-rw-r--r-- | tests/test_framework/phpbb_ui_test_case.php | 49 |
8 files changed, 69 insertions, 19 deletions
diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php index 806edb963a..565e9a48eb 100644 --- a/tests/cache/cache_memory.php +++ b/tests/cache/cache_memory.php @@ -18,7 +18,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory /** * Set cache path */ - function phpbb_cache_memory() + function __construct() { } diff --git a/tests/console/user/base.php b/tests/console/user/base.php index b84c0bb267..2fb7ee0394 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -94,6 +94,9 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case 'auth.provider_collection', $provider_collection ); + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); parent::setUp(); } diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php index 88df782faa..7a0a6ca941 100644 --- a/tests/functional/acp_profile_field_test.php +++ b/tests/functional/acp_profile_field_test.php @@ -28,18 +28,20 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case public function data_add_profile_field() { return array( - array('bool', 'profilefields.type.bool', + array('profilefields.type.bool', array( + 'field_ident' => 'bool', + 'lang_name' => 'bool', 'lang_options[0]' => 'foo', 'lang_options[1]' => 'bar', ), - array(), ), - array('dropdown', 'profilefields.type.dropdown', + array('profilefields.type.dropdown', array( + 'field_ident' => 'dropdown', + 'lang_name' => 'dropdown', 'lang_options' => "foo\nbar\nbar\nfoo", ), - array(), ), ); } @@ -47,13 +49,12 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case /** * @dataProvider data_add_profile_field */ - public function test_add_profile_field($name, $type, $page1_settings, $page2_settings) + public function test_add_profile_field($type, $page1_settings) { // Custom profile fields page $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid); // these language strings are html $form = $crawler->selectButton('Create new field')->form(array( - 'field_ident' => $name, 'field_type' => $type, )); $crawler = self::submit($form); @@ -63,7 +64,7 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case $crawler = self::submit($form); // Fill form for profile field specific options - $form = $crawler->selectButton('Save')->form($page2_settings); + $form = $crawler->selectButton('Save')->form(); $crawler= self::submit($form); $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text()); diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index db9b6e0c90..88680d5719 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -82,6 +82,10 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google); $phpbb_container->set('auth.provider_collection', $provider_collection); $phpbb_container->set('notification_manager', $notification_manager); + + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); } public function test_user_delete() diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 25042d9f1b..30253ccc2f 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -46,6 +46,9 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case 'auth.provider_collection', $provider_collection ); + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); } public function first_last_post_data() diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index 143c05aa9c..6407dca894 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -20,16 +20,6 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $this->type_cast_helper = new \phpbb\request\type_cast_helper(); } - public function test_addslashes_recursively() - { - $data = array('some"string' => array('that"' => 'really"', 'needs"' => '"escaping')); - $expected = array('some\\"string' => array('that\\"' => 'really\\"', 'needs\\"' => '\\"escaping')); - - $this->type_cast_helper->addslashes_recursively($data); - - $this->assertEquals($expected, $data); - } - public function test_simple_recursive_set_var() { $data = 'eviL<3'; diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 40cb7d2f04..0177eb4259 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -109,7 +109,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base if ($expected_error !== false) { - $this->setExpectedTriggerError(E_USER_ERROR, $user->lang[$expected_error]); + $this->setExpectedTriggerError(E_USER_WARNING, $user->lang[$expected_error]); } $result = redirect($test, true, $disable_cd_check); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index d38d14f45c..15a1cd375e 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -192,6 +192,13 @@ class phpbb_ui_test_case extends phpbb_test_case } } + $install_config_file = $phpbb_root_path . 'store/install_config.php'; + + if (file_exists($install_config_file)) + { + unlink($install_config_file); + } + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder ->with_environment('installer') @@ -205,11 +212,14 @@ class phpbb_ui_test_case extends phpbb_test_case ], 'cache.driver.class' => 'phpbb\cache\driver\file' ]) + ->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx)) ->without_compiled_container() ->get_container(); $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->register('installer.install_finish.install_extensions')->setSynthetic(true); + $container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task()); $container->compile(); $language = $container->get('language'); @@ -338,6 +348,12 @@ class phpbb_ui_test_case extends phpbb_test_case { if (!$this->cache) { + global $phpbb_container, $phpbb_root_path; + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + $this->cache = new \phpbb\cache\driver\file; } @@ -590,4 +606,37 @@ class phpbb_ui_test_case extends phpbb_test_case $this->getDriver()->takeScreenshot($screenshot); } + + /** + * Wait for AJAX. Should be called after an AJAX action is made. + * + * @param string $framework javascript frameworks jquery|prototype|dojo + * @throws \Facebook\WebDriver\Exception\NoSuchElementException + * @throws \Facebook\WebDriver\Exception\TimeOutException + */ + public function waitForAjax($framework = 'jquery') + { + switch ($framework) + { + case 'jquery': + $code = 'return jQuery.active;'; + break; + case 'prototype': + $code = 'return Ajax.activeRequestCount;'; + break; + case 'dojo': + $code = 'return dojo.io.XMLHTTPTransport.inFlight.length;'; + break; + default: + throw new \RuntimeException('Unsupported framework'); + break; + } + // wait for at most 30s, retry every 2000ms (2s) + $driver = $this->getDriver(); + $driver->wait(30, 2000)->until( + function () use ($driver, $code) { + return !$driver->executeScript($code); + } + ); + } } |