diff options
| author | stevendegroote <stevendegroote@gmail.com> | 2019-09-17 23:15:54 +0200 |
|---|---|---|
| committer | stevendegroote <stevendegroote@gmail.com> | 2019-09-17 23:15:54 +0200 |
| commit | f8967fec78d826ea8d9ca34f65966ff8a7674b47 (patch) | |
| tree | f9c5f408e7764ec6343e084e7fc6d62d07e3400f /tests/functional | |
| parent | ce93b224107a65b43253c36812b636321eb55a78 (diff) | |
| parent | 4db585a4cb2e5359074a82ef088574609155294b (diff) | |
| download | forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.gz forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.bz2 forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.xz forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.zip | |
Merge branch '3.2.x' into ticket/16159
Diffstat (limited to 'tests/functional')
| -rw-r--r-- | tests/functional/acp_attachments_test.php | 78 | ||||
| -rw-r--r-- | tests/functional/acp_profile_field_test.php | 15 | ||||
| -rw-r--r-- | tests/functional/extension_acp_test.php | 4 | ||||
| -rw-r--r-- | tests/functional/extension_controller_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/extension_global_lang_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/extension_module_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/extension_permission_lang_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/fileupload_form_test.php | 1 | ||||
| -rw-r--r-- | tests/functional/fileupload_remote_test.php | 4 | ||||
| -rw-r--r-- | tests/functional/metadata_manager_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/posting_test.php | 2 | ||||
| -rw-r--r-- | tests/functional/user_password_reset_test.php | 57 |
12 files changed, 62 insertions, 109 deletions
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php deleted file mode 100644 index 8e810a508a..0000000000 --- a/tests/functional/acp_attachments_test.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/** - * - * This file is part of the phpBB Forum Software package. - * - * @copyright (c) phpBB Limited <https://www.phpbb.com> - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -/** - * @group functional - */ -class phpbb_functional_acp_attachments_test extends phpbb_functional_test_case -{ - public function data_imagick_path_linux() - { - return array( - array('/usr/bin', 'Configuration updated successfully'), - array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'), - array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'), - ); - } - - /** - * @dataProvider data_imagick_path_linux - */ - public function test_imagick_path_linux($imagick_path, $expected) - { - if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') - { - $this->markTestSkipped('Unable to test linux specific paths on other OS.'); - } - - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); - - $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); - - $crawler = self::submit($form); - $this->assertContains($expected, $crawler->filter('#main')->text()); - } - - public function data_imagick_path_windows() - { - return array( - array('C:\Windows', 'Configuration updated successfully'), - array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'), - array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'), - ); - } - - /** - * @dataProvider data_imagick_path_windows - */ - public function test_imagick_path_windows($imagick_path, $expected) - { - if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') - { - $this->markTestSkipped('Unable to test windows specific paths on other OS.'); - } - - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); - - $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); - - $crawler = self::submit($form); - $this->assertContains($expected, $crawler->filter('#main')->text()); - } -} 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/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 8a71a5ce04..ce0f4911e3 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -26,7 +26,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures); } @@ -133,7 +133,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) { - $text = $crawler->filter('dl')->eq($i)->text(); + $text = trim($crawler->filter('dl')->eq($i)->text()); $match = false; diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 18eb9ad4c6..58c3878b8b 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -34,7 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index f615114c08..a1e2547745 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -30,7 +30,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index 95107665cd..d3a66b9b35 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -29,7 +29,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 92d8d596c7..f570d45215 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -30,7 +30,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index d381fa1ae2..b0780172ff 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -99,7 +99,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(array( 'config[check_attachment_content]' => 0, - 'config[img_imagick]' => '', )); self::submit($form); diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 88f8999005..426ebcee53 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -102,7 +102,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case ->set_allowed_extensions(array('gif')) ->set_max_filesize(2000); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); $this->assertTrue(file_exists($file->get('filename'))); $this->assertTrue($file->is_uploaded()); } @@ -115,7 +115,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals(1, count($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } } diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index 0d2fdf082e..8456c40f00 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -35,7 +35,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8e6328d1d3..764376a945 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -235,7 +235,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case )); $crawler = self::submit($form); $this->assertContains( - '<span style="font-weight: bold">My signature</span>', + '<strong class="text-strong">My signature</strong>', $crawler->filter('#preview .signature')->html() ); } diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index 3da78407cf..2361eed066 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -21,25 +21,56 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_password_reset() { $this->add_lang('ucp'); - $user_id = $this->create_user('reset-password-test-user'); + $user_id = $this->create_user('reset-password-test-user', 'reset-password-test-user@test.com'); + // test without email + $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); + $form = $crawler->selectButton('submit')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); + + // test with non-existent email $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(array( - 'username' => 'reset-password-test-user', + 'email' => 'non-existent@email.com', )); $crawler = self::submit($form); - $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); + // test with correct email $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(array( - 'username' => 'reset-password-test-user', - 'email' => 'nobody@example.com', + 'email' => 'reset-password-test-user@test.com', + )); + $crawler = self::submit($form); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); + + // Check if columns in database were updated for password reset + $this->get_user_data('reset-password-test-user'); + $this->assertNotNull($this->user_data['user_actkey']); + $this->assertNotNull($this->user_data['user_newpasswd']); + + // Create another user with the same email + $this->create_user('reset-password-test-user1', 'reset-password-test-user@test.com'); + + // Test that username is now also required + $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); + $form = $crawler->selectButton('submit')->form(array( + 'email' => 'reset-password-test-user@test.com', + )); + $crawler = self::submit($form); + $this->assertContainsLang('EMAIL_NOT_UNIQUE', $crawler->text()); + + // Provide both username and email + $form = $crawler->selectButton('submit')->form(array( + 'email' => 'reset-password-test-user@test.com', + 'username' => 'reset-password-test-user1', )); $crawler = self::submit($form); - $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text()); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); // Check if columns in database were updated for password reset - $this->get_user_data(); + $this->get_user_data('reset-password-test-user1'); $this->assertNotNull($this->user_data['user_actkey']); $this->assertNotNull($this->user_data['user_newpasswd']); @@ -73,7 +104,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_activate_new_password($expected, $user_id, $act_key) { $this->add_lang('ucp'); - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id; $act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key; @@ -119,7 +150,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_acivateAfterDeactivate() { // User is active, actkey should not exist - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertEmpty($this->user_data['user_actkey']); $this->login(); @@ -143,7 +174,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $crawler = self::request('GET', preg_replace('#(.+)(adm/index.php.+)#', '$2', $link->getUri())); // Ensure again that actkey is empty after deactivation - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertEmpty($this->user_data['user_actkey']); // Force reactivation of account and check that act key is not empty anymore @@ -152,16 +183,16 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $crawler = self::submit($form, array('action' => 'reactivate')); $this->assertContainsLang('FORCE_REACTIVATION_SUCCESS', $crawler->filter('html')->text()); - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertNotEmpty($this->user_data['user_actkey']); } - protected function get_user_data() + protected function get_user_data($username) { $db = $this->get_db(); $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " - WHERE username = 'reset-password-test-user'"; + WHERE username = '" . $db->sql_escape($username) . "'"; $result = $db->sql_query($sql); $this->user_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); |
