From 18e82931dccbe0537a06f2e6570653e19db372dd Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 11 May 2013 22:56:38 +0300 Subject: [ticket/develop/10772] Unit tests for forum specific style Unit tests for forum specific style for 3.1 branch PHPBB3-10772 --- tests/functional/forum_style_test.php | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/functional/forum_style_test.php (limited to 'tests/functional') diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php new file mode 100644 index 0000000000..f9927454ad --- /dev/null +++ b/tests/functional/forum_style_test.php @@ -0,0 +1,53 @@ +request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/theme/print.css', $this->client->getResponse()->getContent()); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/theme/print.css', $this->client->getResponse()->getContent()); + + // Insert new style and change forum style + $db = $this->get_db(); + $db->sql_multi_insert(STYLES_TABLE, array( + 'style_id' => 2, + 'style_name' => 'test_style', + 'style_copyright' => '', + 'style_active' => 1, + 'style_path' => 'test_style', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 1, + 'style_parent_tree' => 'prosilver', + )); + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); + + // Test with custom style + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/theme/print.css', $this->client->getResponse()->getContent()); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/theme/print.css', $this->client->getResponse()->getContent()); + + // Undo changes + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); + $db->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE style_id = 2'); + } +} -- cgit v1.2.1 From 0a707dd1ceec36b53ea45889b27051ed8a9a4e4b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 11:35:46 +0200 Subject: [ticket/11531] Add basic set of functional tests for new avatar system This currently includes tests for the gravatar, remote avatar, and upload avatar drivers. The local avatar driver is currently not supported. Two tests currently fail and have been marked as incomplete. One failure is due to an issue with Symfony's DomCrawler that exists in Symfony < 2.2. The other one is caused by a bug in the way remote avatars are treated. According to my tests, this bug also exists in phpBB 3.0.11 and has been reported in the tracker: http://tracker.phpbb.com/browse/PHPBB3-11534 PHPBB3-11531 --- tests/functional/avatar_test.php | 210 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 tests/functional/avatar_test.php (limited to 'tests/functional') diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php new file mode 100644 index 0000000000..b6dcc16e8a --- /dev/null +++ b/tests/functional/avatar_test.php @@ -0,0 +1,210 @@ +path = __DIR__ . '/fixtures/files/'; + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/board', 'ucp')); + } + + public function test_acp_settings() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + // Check the default entries we should have + $this->assertContains($this->lang('ALLOW_GRAVATAR'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_gravatar]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + } + + public function test_gravatar_avatar() + { + // Get ACP settings + $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $this->form_content = $form->getValues(); + + // Check if required form elements exist + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContains($this->lang('AVATAR_DRIVER_GRAVATAR_TITLE'), $crawler->filter('#avatar_driver')->text()); + $this->assertContains($this->lang('GRAVATAR_AVATAR_EMAIL'), $crawler->text()); + + // Submit gravatar with correct email and correct size + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test@example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + + // Submit gravatar with correct mail but incorrect size + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test@example.com'); + $form['avatar_gravatar_width']->setValue(120); + $form['avatar_gravatar_height']->setValue(120); + $crawler = $this->client->submit($form); + $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], + $this->form_content['config[avatar_min_width]'], + $this->form_content['config[avatar_min_height]'], + $this->form_content['config[avatar_max_width]'], + $this->form_content['config[avatar_max_height]'], + '120', + '120' + ), $crawler->text()); + + // Submit gravatar with incorrect email and correct size + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test.example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + } + + public function test_upload_avatar() + { + // Check if required form elements exist + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains($this->lang('AVATAR_DRIVER_UPLOAD_TITLE'), $crawler->filter('#avatar_driver')->text()); + $this->assertContains($this->lang('UPLOAD_AVATAR_FILE'), $crawler->text()); + $this->assertContains($this->lang('UPLOAD_AVATAR_URL'), $crawler->text()); + + // Upload remote avatar with correct size and correct link + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and default size = 80px + $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + + // This will fail as the upload avatar currently expects a file that ends with an extension, e.g. .jpg + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and size (s) = 80px + $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('AVATAR_URL_INVALID'), $crawler->text()); + + // Submit gravatar with correct email and correct size + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $this->markTestIncomplete('Test fails due to bug in DomCrawler with Symfony < 2.2: https://github.com/symfony/symfony/issues/4674.'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + $form['avatar_upload_file']->setValue($this->path . 'valid.jpg'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + } + + public function test_remote_avatar() + { + // Get ACP settings + $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $this->form_content = $form->getValues(); + + // Check if required form elements exist + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains($this->lang('AVATAR_DRIVER_REMOTE_TITLE'), $crawler->filter('#avatar_driver')->text()); + $this->assertContains($this->lang('LINK_REMOTE_AVATAR'), $crawler->text()); + $this->assertContains($this->lang('LINK_REMOTE_SIZE'), $crawler->text()); + + // Set remote avatar with correct size and correct link + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_remote'); + // use default gravatar supplied by test@example.com and default size = 80px + $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $form['avatar_remote_width']->setValue(80); + $form['avatar_remote_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + + // Set remote avatar with incorrect size + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_remote'); + // use default gravatar supplied by test@example.com and size (s) = 80px + $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $form['avatar_remote_width']->setValue(120); + $form['avatar_remote_height']->setValue(120); + $crawler = $this->client->submit($form); + $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], + $this->form_content['config[avatar_min_width]'], + $this->form_content['config[avatar_min_height]'], + $this->form_content['config[avatar_max_width]'], + $this->form_content['config[avatar_max_height]'], + '120', + '120' + ), $crawler->text()); + + // Enter correct data in form entries but select incorrect avatar driver + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and size (s) = 80px + $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $form['avatar_remote_width']->setValue(80); + $form['avatar_remote_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('NO_AVATAR_SELECTED'), $crawler->text()); + + /* + * Enter incorrect link to a remote avatar_driver + * Due to the fact that this link to phpbb.com will not serve a 404 error but rather a 404 page, + * the remote avatar will think that this is a properly working avatar. This Bug also exists in + * the current phpBB 3.0.11 release. + */ + $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + $this->markTestIncomplete('Test currently fails because the remote avatar does not seem to check if it is an image'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_remote'); + // use random incorrect link to phpBB.com + $form['avatar_remote_url']->setValue('https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $form['avatar_remote_width']->setValue(80); + $form['avatar_remote_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('NO_AVATAR_SELECTED'), $crawler->text()); + } +} -- cgit v1.2.1 From c2f5ba69f0fb03a30d4f3cbf1e6d49e019edea7c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 12 May 2013 12:43:15 +0300 Subject: [ticket/develop/10772] Fix copyright year PHPBB3-10772 --- tests/functional/forum_style_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php index f9927454ad..1f38c2d057 100644 --- a/tests/functional/forum_style_test.php +++ b/tests/functional/forum_style_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From 9c4d8b3193ca853d67c0098e1627db17f7dd0311 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 13 May 2013 11:57:41 +0200 Subject: [ticket/11531] Add acp and ucp groups functional tests for avatars The test for the acp and ucp groups settings are currently marked as incomplete due to a bug that causes the settings to not show an error when incorrect data is entered. However, the avatar data is not saved. That means that even though the error treatment seems to correctly work, the user is never informed of the issues with the submitted avatar data. PHPBB3-11531 --- tests/functional/avatar_acp_test.php | 147 +++++++++++++++++++++++++++++++++++ tests/functional/avatar_test.php | 46 ++++++++++- 2 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 tests/functional/avatar_acp_test.php (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php new file mode 100644 index 0000000000..b359212be2 --- /dev/null +++ b/tests/functional/avatar_acp_test.php @@ -0,0 +1,147 @@ +path = __DIR__ . '/fixtures/files/'; + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); + } + + public function test_acp_settings() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + $this->assert_response_success(); + // Check the default entries we should have + $this->assertContains($this->lang('ALLOW_GRAVATAR'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_gravatar]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + } + + public function test_user_acp_settings() + { + $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); + $this->assert_response_success(); + + // Select "Avatar" in the drop-down menu + $form = $crawler->selectButton($this->lang('GO'))->form(); + $form['mode']->select('avatar'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test@example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('USER_AVATAR_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); + $this->assert_response_success(); + + // Select "Avatar" in the drop-down menu + $form = $crawler->selectButton($this->lang('GO'))->form(); + $form['mode']->select('avatar'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + + // Test uploading a remote avatar + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and default size = 80px + $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('USER_AVATAR_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); + $this->assert_response_success(); + + // Select "Avatar" in the drop-down menu + $form = $crawler->selectButton($this->lang('GO'))->form(); + $form['mode']->select('avatar'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + + // Submit gravatar with incorrect email and correct size + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test.example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + } + + public function test_group_acp_settings() + { + // Test setting group avatar of admin group + $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test@example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + + // Test uploading a remote avatar + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and default size = 80px + $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + + // Submit gravatar with incorrect email and correct size + $this->markTestIncomplete('No error when submitting incorrect acp group settings. This needs to be fixed ASAP.'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test.example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + } +} diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php index b6dcc16e8a..a29fb5ddb9 100644 --- a/tests/functional/avatar_test.php +++ b/tests/functional/avatar_test.php @@ -21,7 +21,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $this->path = __DIR__ . '/fixtures/files/'; $this->login(); $this->admin_login(); - $this->add_lang(array('acp/board', 'ucp')); + $this->add_lang(array('acp/board', 'ucp', 'acp/groups')); } public function test_acp_settings() @@ -207,4 +207,48 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $crawler = $this->client->submit($form); $this->assertContains($this->lang('NO_AVATAR_SELECTED'), $crawler->text()); } + + + public function test_group_ucp_settings() + { + // Test setting group avatar of admin group + $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test@example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + + // Test uploading a remote avatar + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_upload'); + // use default gravatar supplied by test@example.com and default size = 80px + $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + // Go back to previous page + $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + + // Submit gravatar with incorrect email and correct size + $this->markTestIncomplete('No error when submitting incorrect ucp group settings. This needs to be fixed ASAP.'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->select('avatar_driver_gravatar'); + $form['avatar_gravatar_email']->setValue('test.example.com'); + $form['avatar_gravatar_width']->setValue(80); + $form['avatar_gravatar_height']->setValue(80); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + } } -- cgit v1.2.1 From 56ac97e819d0a31d24120bf4f92f2547fad000a2 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 16 May 2013 09:24:16 +0300 Subject: [ticket/10772] Functional tests for forum style PHPBB3-10772 --- tests/functional/forum_style_test.php | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/functional/forum_style_test.php (limited to 'tests/functional') diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php new file mode 100644 index 0000000000..5d95538f68 --- /dev/null +++ b/tests/functional/forum_style_test.php @@ -0,0 +1,51 @@ +request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + + $crawler = $this->request('GET', 'viewtopic.php?t=1'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + } + + public function test_custom_forum_style() + { + $db = $this->get_db(); + $this->add_style(2, 'test_style'); + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + + $crawler = $this->request('GET', 'viewtopic.php?t=1'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); + $this->delete_style(2, 'test_style'); + } +} -- cgit v1.2.1 From 76453b48ddededb9397e81aea8a75f419fcdc24b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 May 2013 18:15:54 +0200 Subject: [ticket/11531] Use assertContainsLang() where possible PHBB3-11531 --- tests/functional/avatar_acp_test.php | 30 ++++++++++----------- tests/functional/avatar_test.php | 52 ++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 41 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php index b359212be2..623911fbf1 100644 --- a/tests/functional/avatar_acp_test.php +++ b/tests/functional/avatar_acp_test.php @@ -29,10 +29,10 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); $this->assert_response_success(); // Check the default entries we should have - $this->assertContains($this->lang('ALLOW_GRAVATAR'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); + $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); // Now start setting the needed settings $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -41,7 +41,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); } public function test_user_acp_settings() @@ -53,7 +53,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -62,7 +62,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('USER_AVATAR_UPDATED'), $crawler->text()); + $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); @@ -72,7 +72,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test uploading a remote avatar $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -80,7 +80,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('USER_AVATAR_UPDATED'), $crawler->text()); + $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); @@ -90,7 +90,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Submit gravatar with incorrect email and correct size $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -99,7 +99,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } public function test_group_acp_settings() @@ -107,7 +107,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case // Test setting group avatar of admin group $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -116,7 +116,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); @@ -128,7 +128,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); @@ -142,6 +142,6 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } } diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php index a29fb5ddb9..e94eb4dcad 100644 --- a/tests/functional/avatar_test.php +++ b/tests/functional/avatar_test.php @@ -29,10 +29,10 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); $this->assert_response_success(); // Check the default entries we should have - $this->assertContains($this->lang('ALLOW_GRAVATAR'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); + $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); // Now start setting the needed settings $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -41,7 +41,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); } public function test_gravatar_avatar() @@ -55,9 +55,9 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); - $this->assertContains($this->lang('AVATAR_DRIVER_GRAVATAR_TITLE'), $crawler->filter('#avatar_driver')->text()); - $this->assertContains($this->lang('GRAVATAR_AVATAR_EMAIL'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); + $this->assertContainsLang('AVATAR_DRIVER_GRAVATAR_TITLE', $crawler->filter('#avatar_driver')->text()); + $this->assertContainsLang('GRAVATAR_AVATAR_EMAIL', $crawler->text()); // Submit gravatar with correct email and correct size $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -66,7 +66,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // Submit gravatar with correct mail but incorrect size $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); @@ -92,7 +92,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } public function test_upload_avatar() @@ -100,9 +100,9 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains($this->lang('AVATAR_DRIVER_UPLOAD_TITLE'), $crawler->filter('#avatar_driver')->text()); - $this->assertContains($this->lang('UPLOAD_AVATAR_FILE'), $crawler->text()); - $this->assertContains($this->lang('UPLOAD_AVATAR_URL'), $crawler->text()); + $this->assertContainsLang('AVATAR_DRIVER_UPLOAD_TITLE', $crawler->filter('#avatar_driver')->text()); + $this->assertContainsLang('UPLOAD_AVATAR_FILE', $crawler->text()); + $this->assertContainsLang('UPLOAD_AVATAR_URL', $crawler->text()); // Upload remote avatar with correct size and correct link $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -110,7 +110,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // This will fail as the upload avatar currently expects a file that ends with an extension, e.g. .jpg $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); @@ -120,7 +120,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // use default gravatar supplied by test@example.com and size (s) = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('AVATAR_URL_INVALID'), $crawler->text()); + $this->assertContainsLang('AVATAR_URL_INVALID', $crawler->text()); // Submit gravatar with correct email and correct size $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); @@ -130,7 +130,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_driver']->select('avatar_driver_upload'); $form['avatar_upload_file']->setValue($this->path . 'valid.jpg'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); } public function test_remote_avatar() @@ -144,9 +144,9 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains($this->lang('AVATAR_DRIVER_REMOTE_TITLE'), $crawler->filter('#avatar_driver')->text()); - $this->assertContains($this->lang('LINK_REMOTE_AVATAR'), $crawler->text()); - $this->assertContains($this->lang('LINK_REMOTE_SIZE'), $crawler->text()); + $this->assertContainsLang('AVATAR_DRIVER_REMOTE_TITLE', $crawler->filter('#avatar_driver')->text()); + $this->assertContainsLang('LINK_REMOTE_AVATAR', $crawler->text()); + $this->assertContainsLang('LINK_REMOTE_SIZE', $crawler->text()); // Set remote avatar with correct size and correct link $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -156,7 +156,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('PROFILE_UPDATED'), $crawler->text()); + $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // Set remote avatar with incorrect size $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); @@ -187,7 +187,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('NO_AVATAR_SELECTED'), $crawler->text()); + $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); /* * Enter incorrect link to a remote avatar_driver @@ -205,7 +205,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('NO_AVATAR_SELECTED'), $crawler->text()); + $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); } @@ -214,7 +214,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // Test setting group avatar of admin group $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains($this->lang('AVATAR_TYPE'), $crawler->text()); + $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -223,7 +223,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); @@ -235,7 +235,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); @@ -249,6 +249,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('EMAIL_INVALID_EMAIL'), $crawler->text()); + $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } } -- cgit v1.2.1 From 79823b9cafb41f4f9405c6a5bf7e0c46b0aa751b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 May 2013 18:17:33 +0200 Subject: [ticket/11531] Remove incomplete flags for tests after merging PR #1404 Issues should be fixed by the now resolved ticket PHPBB3-11535: http://tracker.phpbb.com/browse/PHPBB3-11535 PHPBB3-11531 --- tests/functional/avatar_acp_test.php | 1 - tests/functional/avatar_test.php | 1 - 2 files changed, 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php index 623911fbf1..efd0317571 100644 --- a/tests/functional/avatar_acp_test.php +++ b/tests/functional/avatar_acp_test.php @@ -135,7 +135,6 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $this->assert_response_success(); // Submit gravatar with incorrect email and correct size - $this->markTestIncomplete('No error when submitting incorrect acp group settings. This needs to be fixed ASAP.'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_gravatar'); $form['avatar_gravatar_email']->setValue('test.example.com'); diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php index e94eb4dcad..4f0f6ee5f7 100644 --- a/tests/functional/avatar_test.php +++ b/tests/functional/avatar_test.php @@ -242,7 +242,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $this->assert_response_success(); // Submit gravatar with incorrect email and correct size - $this->markTestIncomplete('No error when submitting incorrect ucp group settings. This needs to be fixed ASAP.'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_gravatar'); $form['avatar_gravatar_email']->setValue('test.example.com'); -- cgit v1.2.1 From 79dd44061bbfeab64dd2ff7b40541612c219c33c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 25 Jun 2013 00:17:51 +0200 Subject: [ticket/11531] Add changes for supporting modified testing framework Additionally, the groups avatar is deleted after the avatar tests in the ucp groups page in order to prevent issues with other tests that expect that no avatar has been set for the admin group. PHPBB3-11531 --- tests/functional/avatar_acp_test.php | 27 ++++++++------------ tests/functional/avatar_test.php | 49 ++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 45 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php index efd0317571..609ccbb477 100644 --- a/tests/functional/avatar_acp_test.php +++ b/tests/functional/avatar_acp_test.php @@ -27,7 +27,6 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case public function test_acp_settings() { $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); // Check the default entries we should have $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); @@ -40,19 +39,18 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['config[allow_avatar_gravatar]']->select(1); $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); } public function test_user_acp_settings() { $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - $this->assert_response_success(); // Select "Avatar" in the drop-down menu $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works @@ -61,17 +59,16 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test@example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - $this->assert_response_success(); // Select "Avatar" in the drop-down menu $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test uploading a remote avatar @@ -79,17 +76,16 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - $this->assert_response_success(); // Select "Avatar" in the drop-down menu $form = $crawler->selectButton($this->lang('GO'))->form(); $form['mode']->select('avatar'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Submit gravatar with incorrect email and correct size @@ -98,7 +94,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test.example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } @@ -106,7 +102,6 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case { // Test setting group avatar of admin group $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works @@ -115,24 +110,22 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test@example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); // Test uploading a remote avatar $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); // Submit gravatar with incorrect email and correct size $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -140,7 +133,7 @@ class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test.example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } } diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php index 4f0f6ee5f7..c96ed46d30 100644 --- a/tests/functional/avatar_test.php +++ b/tests/functional/avatar_test.php @@ -27,7 +27,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case public function test_acp_settings() { $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); // Check the default entries we should have $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); @@ -40,7 +39,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['config[allow_avatar_gravatar]']->select(1); $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); } @@ -48,13 +47,11 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case { // Get ACP settings $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $this->form_content = $form->getValues(); // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); $this->assertContainsLang('AVATAR_DRIVER_GRAVATAR_TITLE', $crawler->filter('#avatar_driver')->text()); $this->assertContainsLang('GRAVATAR_AVATAR_EMAIL', $crawler->text()); @@ -65,7 +62,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test@example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // Submit gravatar with correct mail but incorrect size @@ -75,7 +72,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test@example.com'); $form['avatar_gravatar_width']->setValue(120); $form['avatar_gravatar_height']->setValue(120); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], $this->form_content['config[avatar_min_width]'], $this->form_content['config[avatar_min_height]'], @@ -91,7 +88,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test.example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); } @@ -99,7 +96,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case { // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $this->assertContainsLang('AVATAR_DRIVER_UPLOAD_TITLE', $crawler->filter('#avatar_driver')->text()); $this->assertContainsLang('UPLOAD_AVATAR_FILE', $crawler->text()); $this->assertContainsLang('UPLOAD_AVATAR_URL', $crawler->text()); @@ -109,27 +105,25 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // This will fail as the upload avatar currently expects a file that ends with an extension, e.g. .jpg $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and size (s) = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('AVATAR_URL_INVALID', $crawler->text()); // Submit gravatar with correct email and correct size $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $this->markTestIncomplete('Test fails due to bug in DomCrawler with Symfony < 2.2: https://github.com/symfony/symfony/issues/4674.'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_upload'); $form['avatar_upload_file']->setValue($this->path . 'valid.jpg'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); } @@ -137,13 +131,11 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case { // Get ACP settings $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $this->form_content = $form->getValues(); // Check if required form elements exist $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $this->assertContainsLang('AVATAR_DRIVER_REMOTE_TITLE', $crawler->filter('#avatar_driver')->text()); $this->assertContainsLang('LINK_REMOTE_AVATAR', $crawler->text()); $this->assertContainsLang('LINK_REMOTE_SIZE', $crawler->text()); @@ -155,19 +147,18 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); // Set remote avatar with incorrect size $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_remote'); // use default gravatar supplied by test@example.com and size (s) = 80px $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $form['avatar_remote_width']->setValue(120); $form['avatar_remote_height']->setValue(120); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], $this->form_content['config[avatar_min_width]'], $this->form_content['config[avatar_min_height]'], @@ -179,14 +170,13 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case // Enter correct data in form entries but select incorrect avatar driver $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and size (s) = 80px $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); /* @@ -196,7 +186,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case * the current phpBB 3.0.11 release. */ $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assert_response_success(); $this->markTestIncomplete('Test currently fails because the remote avatar does not seem to check if it is an image'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_remote'); @@ -204,7 +193,7 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_remote_url']->setValue('https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); $form['avatar_remote_width']->setValue(80); $form['avatar_remote_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); } @@ -213,7 +202,6 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case { // Test setting group avatar of admin group $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); // Test if setting a gravatar avatar properly works @@ -222,24 +210,22 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test@example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); // Test uploading a remote avatar $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['avatar_driver']->select('avatar_driver_upload'); // use default gravatar supplied by test@example.com and default size = 80px $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); // Go back to previous page $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); // Submit gravatar with incorrect email and correct size $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -247,7 +233,14 @@ class phpbb_functional_avatar_test extends phpbb_functional_test_case $form['avatar_gravatar_email']->setValue('test.example.com'); $form['avatar_gravatar_width']->setValue(80); $form['avatar_gravatar_height']->setValue(80); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); + + // Delete avatar + $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_delete']->tick(); + $crawler = self::submit($form); + $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); } } -- cgit v1.2.1 From 599f83395f90c9a899b0e639ba5acacfb8ae372b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 11 Jul 2013 16:08:15 -0400 Subject: [ticket/11548] Run array_map on complete error array and not just colour_error Up to now the array_map() that turns error messages into the localized output was only ran if the group's color was set. With this patch it'll run the array_map() on the complete error array if it's not empty. PHPBB3-11548 --- tests/functional/ucp_groups_test.php | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 9c6b1edc5e..7c50f7bb24 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -18,4 +18,54 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te { return 'ucp.php?i=groups&mode=manage&action=edit'; } + + // Enable all avatars in the ACP + private function enable_all_avatars() + { + $this->add_lang('acp/board'); + + $crawler = $this->request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); + // Check the default entries we should have + $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + } + + public function group_avatar_min_max_data() + { + return array( + array('uploadurl', 'foo', 'TOO_SHORT'), + array('uploadurl', 'foobar', 'AVATAR_URL_INVALID'), + array('uploadurl', str_repeat('f', 256), 'TOO_LONG'), + array('remotelink', 'foo', 'TOO_SHORT'), + array('remotelink', 'foobar', 'AVATAR_URL_INVALID'), + array('remotelink', str_repeat('f', 256), 'TOO_LONG'), + ); + } + + /** + * @dataProvider group_avatar_min_max_data + */ + public function test_group_avatar_min_max($form_name, $input, $expected) + { + $this->login(); + $this->admin_login(); + $this->add_lang(array('ucp', 'acp/groups')); + $this->enable_all_avatars(); + + $crawler = $this->request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form[$form_name]->setValue($input); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang($expected), $crawler->text()); + } } -- cgit v1.2.1 From 94e5bfaadad3be2bcda5347754c3f1b5be33c620 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 11 Jul 2013 13:09:20 -0400 Subject: [ticket/10772] Updating tests PHPBB3-10772 --- tests/functional/forum_style_test.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php index 5d95538f68..59f7341eb6 100644 --- a/tests/functional/forum_style_test.php +++ b/tests/functional/forum_style_test.php @@ -14,16 +14,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case { public function test_default_forum_style() { - $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); - $crawler = $this->request('GET', 'viewtopic.php?t=1'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1'); $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); - $crawler = $this->request('GET', 'viewtopic.php?t=1&view=next'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); } @@ -33,16 +30,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $this->add_style(2, 'test_style'); $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); - $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); - $crawler = $this->request('GET', 'viewtopic.php?t=1'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1'); $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); - $crawler = $this->request('GET', 'viewtopic.php?t=1&view=next'); - $this->assert_response_success(); + $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); -- cgit v1.2.1 From 2667c3a527b3a2362370583446231391a4354565 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 11 Jul 2013 17:34:34 -0400 Subject: [ticket/11548] Use new static methods for request and submit PHPBB3-11548 --- tests/functional/ucp_groups_test.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 7c50f7bb24..0d9ef22798 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -24,7 +24,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te { $this->add_lang('acp/board'); - $crawler = $this->request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); // Check the default entries we should have $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); @@ -35,7 +35,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te $form['config[allow_avatar_local]']->select(1); $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); } @@ -61,11 +61,10 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te $this->add_lang(array('ucp', 'acp/groups')); $this->enable_all_avatars(); - $crawler = $this->request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); - $this->assert_response_success(); + $crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form[$form_name]->setValue($input); - $crawler = $this->client->submit($form); + $crawler = self::submit($form); $this->assertContains($this->lang($expected), $crawler->text()); } } -- cgit v1.2.1 From da8e35ac77c5d78f327d08fa1a9d0ff21ed38e83 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Jul 2013 13:40:30 -0400 Subject: [ticket/11548] Fix incorrect usage of array_map on acp groups page The array_map was only ran on small parts of the actual error array instead of the whole one. This resulted in the output of the language variables' names rather than their actual value. PHPBB3-11548 --- tests/functional/common_groups_test.php | 49 +++++++++++++++++++++++++++++++++ tests/functional/ucp_groups_test.php | 49 --------------------------------- 2 files changed, 49 insertions(+), 49 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index 7c88ec900d..427a930cb9 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -14,6 +14,26 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test { abstract protected function get_url(); + // Enable all avatars in the ACP + protected function enable_all_avatars() + { + $this->add_lang('acp/board'); + + $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); + // Check the default entries we should have + $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = self::submit($form); + $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + } + public function groups_manage_test_data() { return array( @@ -41,4 +61,33 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test $crawler = self::submit($form); $this->assertContains($this->lang($expected), $crawler->text()); } + + public function group_avatar_min_max_data() + { + return array( + array('uploadurl', 'foo', 'TOO_SHORT'), + array('uploadurl', 'foobar', 'AVATAR_URL_INVALID'), + array('uploadurl', str_repeat('f', 256), 'TOO_LONG'), + array('remotelink', 'foo', 'TOO_SHORT'), + array('remotelink', 'foobar', 'AVATAR_URL_INVALID'), + array('remotelink', str_repeat('f', 256), 'TOO_LONG'), + ); + } + + /** + * @dataProvider group_avatar_min_max_data + */ + public function test_group_avatar_min_max($form_name, $input, $expected) + { + $this->login(); + $this->admin_login(); + $this->add_lang(array('ucp', 'acp/groups')); + $this->enable_all_avatars(); + + $crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form[$form_name]->setValue($input); + $crawler = self::submit($form); + $this->assertContains($this->lang($expected), $crawler->text()); + } } diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 0d9ef22798..9c6b1edc5e 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -18,53 +18,4 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te { return 'ucp.php?i=groups&mode=manage&action=edit'; } - - // Enable all avatars in the ACP - private function enable_all_avatars() - { - $this->add_lang('acp/board'); - - $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); - // Check the default entries we should have - $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); - - // Now start setting the needed settings - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['config[allow_avatar_local]']->select(1); - $form['config[allow_avatar_remote]']->select(1); - $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = self::submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); - } - - public function group_avatar_min_max_data() - { - return array( - array('uploadurl', 'foo', 'TOO_SHORT'), - array('uploadurl', 'foobar', 'AVATAR_URL_INVALID'), - array('uploadurl', str_repeat('f', 256), 'TOO_LONG'), - array('remotelink', 'foo', 'TOO_SHORT'), - array('remotelink', 'foobar', 'AVATAR_URL_INVALID'), - array('remotelink', str_repeat('f', 256), 'TOO_LONG'), - ); - } - - /** - * @dataProvider group_avatar_min_max_data - */ - public function test_group_avatar_min_max($form_name, $input, $expected) - { - $this->login(); - $this->admin_login(); - $this->add_lang(array('ucp', 'acp/groups')); - $this->enable_all_avatars(); - - $crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form[$form_name]->setValue($input); - $crawler = self::submit($form); - $this->assertContains($this->lang($expected), $crawler->text()); - } } -- cgit v1.2.1 From 01b9f9f9b6f14d602ce57a37f0969707d1f0c41b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Jul 2013 14:38:18 -0400 Subject: [ticket/11548] Fix test errors in groups test on develop This will fix the errors that appeared in the functional groups test due to the changes in the new avatar system. The patch will make them work again. PHPBB3-11548 --- tests/functional/common_groups_test.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index f6b447dc90..6c6572af62 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -84,19 +84,19 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test public function group_avatar_min_max_data() { return array( - array('uploadurl', 'foo', 'TOO_SHORT'), - array('uploadurl', 'foobar', 'AVATAR_URL_INVALID'), - array('uploadurl', str_repeat('f', 256), 'TOO_LONG'), - array('remotelink', 'foo', 'TOO_SHORT'), - array('remotelink', 'foobar', 'AVATAR_URL_INVALID'), - array('remotelink', str_repeat('f', 256), 'TOO_LONG'), + array('avatar_driver_upload', 'avatar_upload_url', 'foo', 'AVATAR_URL_INVALID'), + array('avatar_driver_upload', 'avatar_upload_url', 'foobar', 'AVATAR_URL_INVALID'), + array('avatar_driver_upload', 'avatar_upload_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'), + array('avatar_driver_remote', 'avatar_remote_url', 'foo', 'AVATAR_URL_INVALID'), + array('avatar_driver_remote', 'avatar_remote_url', 'foobar', 'AVATAR_URL_INVALID'), + array('avatar_driver_remote', 'avatar_remote_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'), ); } /** * @dataProvider group_avatar_min_max_data */ - public function test_group_avatar_min_max($form_name, $input, $expected) + public function test_group_avatar_min_max($avatar_type, $form_name, $input, $expected) { $this->login(); $this->admin_login(); @@ -105,6 +105,7 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test $crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['avatar_driver']->setValue($avatar_type); $form[$form_name]->setValue($input); $crawler = self::submit($form); $this->assertContains($this->lang($expected), $crawler->text()); -- cgit v1.2.1 From 0297b88aafd3ef12217965f2879af9f9fd12d91f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 15:41:52 -0400 Subject: [ticket/9657] Add unit tests for softdeleting and moving posts/topics PHPBB3-9657 --- tests/functional/softdelete_test.php | 439 +++++++++++++++++++++++++++++++++++ 1 file changed, 439 insertions(+) create mode 100644 tests/functional/softdelete_test.php (limited to 'tests/functional') diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php new file mode 100644 index 0000000000..0ebbab66ab --- /dev/null +++ b/tests/functional/softdelete_test.php @@ -0,0 +1,439 @@ +login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Soft Delete #1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Soft Delete #2', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + } + + public function test_create_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'initial comparison'); + + // Test creating topic + $post = $this->create_topic($this->data['forums']['Soft Delete #1'], 'Soft Delete Topic #1', 'This is a test topic posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Soft Delete Topic #1', $crawler->filter('html')->text()); + $this->data['topics']['Soft Delete Topic #1'] = (int) $post['topic_id']; + $this->data['posts']['Soft Delete Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after creating topic #1'); + + // Test creating a reply + $post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text()); + $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'], + ), 'after replying'); + } + + public function test_softdelete_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'], + ), 'before softdelete'); + + $this->add_lang('posting'); + $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#2']}&sid={$this->sid}"); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_DELETED', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after softdelete'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + } + + public function test_move_softdeleted_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before moving #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after moving #2'); + } + + public function test_softdelete_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before softdeleting #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before softdeleting #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('posting'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('delete_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after moving #2'); + } + + public function test_move_softdeleted_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'before moving #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #1']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #2'); + } + + public function assert_forum_details($forum_id, $details, $additional_error_message = '') + { + $this->db = $this->get_db(); + + $sql = 'SELECT ' . implode(', ', array_keys($details)) . ' + FROM phpbb_forums + WHERE forum_id = ' . (int) $forum_id; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}"); + } + + public function load_ids($data) + { + $this->db = $this->get_db(); + + if (!empty($data['forums'])) + { + $sql = 'SELECT * + FROM phpbb_forums + WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['forum_name'], $data['forums'])) + { + $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['topics'])) + { + $sql = 'SELECT * + FROM phpbb_topics + WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['topic_title'], $data['topics'])) + { + $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['posts'])) + { + $sql = 'SELECT * + FROM phpbb_posts + WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['post_subject'], $data['posts'])) + { + $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; + } + } + $this->db->sql_freeresult($result); + } + } +} -- cgit v1.2.1 From a01d8cdfa33467f580edb77dbd10185de556cce2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 21:20:33 -0400 Subject: [ticket/9657] Add functional test for restoring a post/topic PHPBB3-9657 --- tests/functional/softdelete_test.php | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index 0ebbab66ab..b42c52b5cf 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -370,6 +370,79 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after moving #2'); } + public function test_restore_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'before restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before restoring #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('RESTORE'))->form(); + $crawler = self::submit($form); + $this->assertContainsLang('RESTORE_POST', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_RESTORED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after restoring #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); -- cgit v1.2.1 From e96932b0e3fd7c3ed4207886afa575d7c1f2f88a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 22:43:11 -0400 Subject: [ticket/9657] Add functional test for splitting topic PHPBB3-9657 --- tests/functional/softdelete_test.php | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index b42c52b5cf..512b9af909 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -443,6 +443,87 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after restoring #2'); } + public function test_split_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before splitting #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before splitting #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('split'); + $crawler = self::submit($form); + $this->assertContainsLang('SPLIT_TOPIC_EXPLAIN', $crawler->text()); + + $form = $crawler->selectButton('Submit')->form(array( + 'subject' => 'Soft Delete Topic #2', + )); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $form['post_id_list'][1]->tick(); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_SPLIT_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertNotContains('Re: Soft Delete Topic #1-#2', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after restoring #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); -- cgit v1.2.1 From da38d13094a1f62038dbb527bff19c43110d99a2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 00:53:55 -0400 Subject: [ticket/9657] Add functional tests for forking a copy PHPBB3-9657 --- tests/functional/softdelete_test.php | 168 +++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index 512b9af909..bd4d34cf99 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -524,6 +524,174 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after restoring #2'); } + public function test_move_topic_back() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + 'Soft Delete Topic #2', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #1']); + $crawler = self::submit($form); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after moving back'); + } + + public function test_merge_topics() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + 'Soft Delete Topic #2', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before merging #1'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('merge_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_MERGE', $crawler->text()); + + $crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}"); + $this->assertContainsLang('MERGE_TOPICS_CONFIRM', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POSTS_MERGED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertContainsLang('POST_DELETED', $crawler->filter('body')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after merging #1'); + } + + public function test_fork_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before forking #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before forking #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('fork'); + $crawler = self::submit($form); + $this->assertContainsLang('FORK_TOPIC', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_FORKED_SUCCESS', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after forking #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'] + 2, + ), 'after forking #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); -- cgit v1.2.1 From 8f95ef55a65cbf58e74840957cf9acfaf9e16d31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 12:27:00 -0400 Subject: [ticket/11685] Remove logout confirmation page PHPBB3-11685 --- tests/functional/auth_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index ff4d3ced5c..cfd85571b7 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -39,7 +39,6 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // logout $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); // look for a register link, which should be visible only when logged out $crawler = self::request('GET', 'index.php'); -- cgit v1.2.1 From 057d860d07fe829104aa938338830787415bc1c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 00:56:37 -0400 Subject: [ticket/11696] Rename db_tools.php so it can be autoloaded PHPBB3-11696 --- tests/functional/extension_controller_test.php | 1 - tests/functional/metadata_manager_test.php | 2 -- 2 files changed, 3 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 9ddf1e3e5c..7d29f0000c 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -6,7 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; /** * @group functional diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index c55e7373ea..651c99a99d 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; - /** * @group functional */ -- cgit v1.2.1 From 5d4c443c2df1685578084417123d52b86eb3bfb6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 01:01:53 -0400 Subject: [ticket/11696] Remove manual loading of db_tools in extension controller test Remember to store the file, before commiting it... PHPBB3-11696 --- tests/functional/extension_module_test.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index c573ea5410..c31a892ce9 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -6,8 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ - -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; /** -- cgit v1.2.1 From cfb13bb5476dfa7895f984405d6a0c40ddcda08e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 23:31:13 -0400 Subject: [ticket/11582] Fix extension permission tests PHPBB3-11582 --- .../ext/foo/bar/event/permission_listener.php | 40 ++++++++++++++++++++++ .../ext/foo/bar/language/en/permissions_foo.php | 3 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/functional/fixtures/ext/foo/bar/event/permission_listener.php (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php new file mode 100644 index 0000000000..dfabf7c540 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -0,0 +1,40 @@ + 'add_permissions', + ); + } + + public function add_permissions($event) + { + $permissions = $event['permissions']; + $permissions['u_foo'] = array('lang' => 'ACL_U_FOO', 'cat' => 'misc'), + $event['permissions'] = $permissions; + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php index cd4b9a32d1..36c84c5209 100644 --- a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -1,6 +1,5 @@ array('lang' => 'Can view foo', 'cat' => 'misc'), + 'ACL_U_FOO' => 'Can view foo', )); -- cgit v1.2.1 From e4a5ce307d49c215b08e35a79147ba2418f133ff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 12:55:03 -0400 Subject: [ticket/11582] Test the event and and fix it. PHPBB3-11582 --- tests/functional/extension_permission_lang_test.php | 2 +- tests/functional/fixtures/ext/foo/bar/event/permission_listener.php | 2 +- tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6c1720735c..badbdbb057 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -75,6 +75,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assertContains('Can attach files', $crawler->filter('body')->text()); // language from ext/foo/bar/language/en/permissions_foo.php - $this->assertContains('Can view foo', $crawler->filter('body')->text()); + $this->assertContains('Can view foobar', $crawler->filter('body')->text()); } } diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php index dfabf7c540..39cb9f8b46 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -34,7 +34,7 @@ class phpbb_ext_foo_bar_event_permission_listener implements EventSubscriberInte public function add_permissions($event) { $permissions = $event['permissions']; - $permissions['u_foo'] = array('lang' => 'ACL_U_FOO', 'cat' => 'misc'), + $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'), $event['permissions'] = $permissions; } } diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php index 36c84c5209..64b497c394 100644 --- a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -1,5 +1,5 @@ 'Can view foo', + 'ACL_U_FOOBAR' => 'Can view foobar with permission foo', )); -- cgit v1.2.1 From a9a6305d939467dd7e3a003a4c52f408c93f8c8c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 13:20:58 -0400 Subject: [ticket/11582] Fix little typo PHPBB3-11582 --- tests/functional/fixtures/ext/foo/bar/event/permission_listener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php index 39cb9f8b46..6986755f71 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -34,7 +34,7 @@ class phpbb_ext_foo_bar_event_permission_listener implements EventSubscriberInte public function add_permissions($event) { $permissions = $event['permissions']; - $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'), + $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'); $event['permissions'] = $permissions; } } -- cgit v1.2.1 From d6a747fbd0f80e9f2c93f09aab6a0a89ec5afd26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jul 2013 17:27:15 +0200 Subject: [ticket/11582] Correctly add all required fixtures PHPBB3-11582 --- tests/functional/extension_permission_lang_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functional') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index badbdbb057..19adb89819 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -18,6 +18,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static protected $fixtures = array( 'foo/bar/language/en/', + 'foo/bar/event/', ); static public function setUpBeforeClass() -- cgit v1.2.1 From 96989e536dd5fc603f3598fa7a2a50414331d76c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Jul 2013 23:55:20 +0200 Subject: [ticket/11531] Use abstract class for avatar tests and unify test cases PHPBB3-11531 --- tests/functional/avatar_acp_groups_test.php | 152 +++++++++++++++++ tests/functional/avatar_acp_test.php | 139 ---------------- tests/functional/avatar_acp_users_test.php | 152 +++++++++++++++++ tests/functional/avatar_test.php | 246 ---------------------------- tests/functional/avatar_ucp_groups_test.php | 151 +++++++++++++++++ tests/functional/avatar_ucp_users_test.php | 151 +++++++++++++++++ tests/functional/common_avatar_test.php | 80 +++++++++ 7 files changed, 686 insertions(+), 385 deletions(-) create mode 100644 tests/functional/avatar_acp_groups_test.php delete mode 100644 tests/functional/avatar_acp_test.php create mode 100644 tests/functional/avatar_acp_users_test.php delete mode 100644 tests/functional/avatar_test.php create mode 100644 tests/functional/avatar_ucp_groups_test.php create mode 100644 tests/functional/avatar_ucp_users_test.php create mode 100644 tests/functional/common_avatar_test.php (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php new file mode 100644 index 0000000000..62b7409bdb --- /dev/null +++ b/tests/functional/avatar_acp_groups_test.php @@ -0,0 +1,152 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Incorrect email supplied for gravatar + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Upload image from remote + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + // Delete avatar image to reset group settings + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_groups_data + */ + public function test_avatar_acp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php deleted file mode 100644 index 609ccbb477..0000000000 --- a/tests/functional/avatar_acp_test.php +++ /dev/null @@ -1,139 +0,0 @@ -path = __DIR__ . '/fixtures/files/'; - $this->login(); - $this->admin_login(); - $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); - } - - public function test_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - // Check the default entries we should have - $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); - $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); - $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); - $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); - - // Now start setting the needed settings - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['config[allow_avatar_local]']->select(1); - $form['config[allow_avatar_gravatar]']->select(1); - $form['config[allow_avatar_remote]']->select(1); - $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); - } - - public function test_user_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } - - public function test_group_acp_settings() - { - // Test setting group avatar of admin group - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } -} diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php new file mode 100644 index 0000000000..38ebcc8940 --- /dev/null +++ b/tests/functional/avatar_acp_users_test.php @@ -0,0 +1,152 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizes + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Remote avatar with correct link + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + // Reset avatar settings + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_users_data + */ + public function test_avatar_acp_users($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php deleted file mode 100644 index c96ed46d30..0000000000 --- a/tests/functional/avatar_test.php +++ /dev/null @@ -1,246 +0,0 @@ -path = __DIR__ . '/fixtures/files/'; - $this->login(); - $this->admin_login(); - $this->add_lang(array('acp/board', 'ucp', 'acp/groups')); - } - - public function test_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - // Check the default entries we should have - $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); - $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); - $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); - $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); - - // Now start setting the needed settings - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['config[allow_avatar_local]']->select(1); - $form['config[allow_avatar_gravatar]']->select(1); - $form['config[allow_avatar_remote]']->select(1); - $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); - } - - public function test_gravatar_avatar() - { - // Get ACP settings - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $this->form_content = $form->getValues(); - - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - $this->assertContainsLang('AVATAR_DRIVER_GRAVATAR_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('GRAVATAR_AVATAR_EMAIL', $crawler->text()); - - // Submit gravatar with correct email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // Submit gravatar with correct mail but incorrect size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(120); - $form['avatar_gravatar_height']->setValue(120); - $crawler = self::submit($form); - $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], - $this->form_content['config[avatar_min_width]'], - $this->form_content['config[avatar_min_height]'], - $this->form_content['config[avatar_max_width]'], - $this->form_content['config[avatar_max_height]'], - '120', - '120' - ), $crawler->text()); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } - - public function test_upload_avatar() - { - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_DRIVER_UPLOAD_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('UPLOAD_AVATAR_FILE', $crawler->text()); - $this->assertContainsLang('UPLOAD_AVATAR_URL', $crawler->text()); - - // Upload remote avatar with correct size and correct link - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // This will fail as the upload avatar currently expects a file that ends with an extension, e.g. .jpg - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_URL_INVALID', $crawler->text()); - - // Submit gravatar with correct email and correct size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->markTestIncomplete('Test fails due to bug in DomCrawler with Symfony < 2.2: https://github.com/symfony/symfony/issues/4674.'); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - $form['avatar_upload_file']->setValue($this->path . 'valid.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - } - - public function test_remote_avatar() - { - // Get ACP settings - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $this->form_content = $form->getValues(); - - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_DRIVER_REMOTE_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('LINK_REMOTE_AVATAR', $crawler->text()); - $this->assertContainsLang('LINK_REMOTE_SIZE', $crawler->text()); - - // Set remote avatar with correct size and correct link - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // Set remote avatar with incorrect size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(120); - $form['avatar_remote_height']->setValue(120); - $crawler = self::submit($form); - $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], - $this->form_content['config[avatar_min_width]'], - $this->form_content['config[avatar_min_height]'], - $this->form_content['config[avatar_max_width]'], - $this->form_content['config[avatar_max_height]'], - '120', - '120' - ), $crawler->text()); - - // Enter correct data in form entries but select incorrect avatar driver - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); - - /* - * Enter incorrect link to a remote avatar_driver - * Due to the fact that this link to phpbb.com will not serve a 404 error but rather a 404 page, - * the remote avatar will think that this is a properly working avatar. This Bug also exists in - * the current phpBB 3.0.11 release. - */ - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->markTestIncomplete('Test currently fails because the remote avatar does not seem to check if it is an image'); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use random incorrect link to phpBB.com - $form['avatar_remote_url']->setValue('https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); - } - - - public function test_group_ucp_settings() - { - // Test setting group avatar of admin group - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - - // Delete avatar - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_delete']->tick(); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - } -} diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php new file mode 100644 index 0000000000..bd34f67491 --- /dev/null +++ b/tests/functional/avatar_ucp_groups_test.php @@ -0,0 +1,151 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizing + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email address + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Correct remote upload avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php new file mode 100644 index 0000000000..6b2c2344b3 --- /dev/null +++ b/tests/functional/avatar_ucp_users_test.php @@ -0,0 +1,151 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizing + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email address + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Correct remote upload avatar + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'PROFILE_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'PROFILE_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + array( + 'PROFILE_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test.php new file mode 100644 index 0000000000..c0f21d07c2 --- /dev/null +++ b/tests/functional/common_avatar_test.php @@ -0,0 +1,80 @@ +path = __DIR__ . '/fixtures/files/'; + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); + $this->set_acp_settings(); + } + + private function set_acp_settings() + { + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + // Check the default entries we should have + $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); + $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_gravatar]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = self::submit($form); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); + } + + public function assert_avatar_submit($expected, $type, $data, $button_text = 'SUBMIT') + { + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang($button_text))->form(); + $form['avatar_driver']->select($type); + + foreach ($data as $key => $value) + { + if (is_array($value)) + { + $form[$key]->$value[0]($value[1]); + } + else + { + $form[$key]->setValue($value); + } + } + + $crawler = self::submit($form); + + try + { + $this->assertContainsLang($expected, $crawler->text()); + } + catch (Exception $e) + { + $this->assertContains($expected, $crawler->text()); + } + } +} -- cgit v1.2.1 From e48f0555e9e40a9e1d3e9a60e25a9f206c565efe Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 14:36:38 +0200 Subject: [ticket/11531] Reduced amount of avatar functional tests to minimum The tests were reduced to only test one case that should be correct and one that should fail. Different test cases have been split up over the specific test files for the acp groups, acp users, ucp groups, and ucp users page. PHPBB3-11531 --- tests/functional/avatar_acp_groups_test.php | 89 ---------------------------- tests/functional/avatar_acp_users_test.php | 91 ----------------------------- tests/functional/avatar_ucp_groups_test.php | 80 ------------------------- tests/functional/avatar_ucp_users_test.php | 89 ---------------------------- 4 files changed, 349 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 62b7409bdb..9fdc29cc76 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -42,95 +42,6 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av 'avatar_gravatar_height' => 120, ), ), - // Incorrect email supplied for gravatar - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Upload image from remote - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), // Delete avatar image to reset group settings array( 'GROUP_UPDATED', diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php index 38ebcc8940..0afd05e530 100644 --- a/tests/functional/avatar_acp_users_test.php +++ b/tests/functional/avatar_acp_users_test.php @@ -22,26 +22,6 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava public function avatar_acp_users_data() { return array( - // Correct gravatar - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Gravatar with incorrect sizes - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), // Gravatar with incorrect email array( 'EMAIL_INVALID_EMAIL', @@ -60,77 +40,6 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', ), ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), // Reset avatar settings array( 'USER_AVATAR_UPDATED', diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php index bd34f67491..233b7d36e1 100644 --- a/tests/functional/avatar_ucp_groups_test.php +++ b/tests/functional/avatar_ucp_groups_test.php @@ -22,44 +22,6 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av public function avatar_ucp_groups_data() { return array( - // Gravatar with correct settings - array( - 'GROUP_UPDATED', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Gravatar with incorrect sizing - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), - // Gravatar with incorrect email address - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Correct remote upload avatar - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), // Incorrect URL array( 'AVATAR_URL_INVALID', @@ -89,48 +51,6 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av 'avatar_remote_height' => 80, ), ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), array( 'GROUP_UPDATED', 'avatar_driver_gravatar', diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php index 6b2c2344b3..fa6282abf4 100644 --- a/tests/functional/avatar_ucp_users_test.php +++ b/tests/functional/avatar_ucp_users_test.php @@ -32,73 +32,6 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava 'avatar_gravatar_height' => 80, ), ), - // Gravatar with incorrect sizing - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), - // Gravatar with incorrect email address - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Correct remote upload avatar - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'PROFILE_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), // Wrong driver selected array( 'NO_AVATAR_SELECTED', @@ -109,28 +42,6 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava 'avatar_remote_height' => 80, ), ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'PROFILE_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), array( 'PROFILE_UPDATED', 'avatar_driver_gravatar', -- cgit v1.2.1 From 865bf0db3d5ca3f8bbadd009ce0a5e8324de49c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 22:35:45 +0200 Subject: [ticket/11720] Add functional test for submitting report as user The already existing functional tests were not ran as the filename was missing the appended "_test". PHPBB3-11720 --- tests/functional/report_post_captcha.php | 61 ------------------------- tests/functional/report_post_captcha_test.php | 66 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 61 deletions(-) delete mode 100644 tests/functional/report_post_captcha.php create mode 100644 tests/functional/report_post_captcha_test.php (limited to 'tests/functional') diff --git a/tests/functional/report_post_captcha.php b/tests/functional/report_post_captcha.php deleted file mode 100644 index af713775c5..0000000000 --- a/tests/functional/report_post_captcha.php +++ /dev/null @@ -1,61 +0,0 @@ -login(); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - } - - public function test_guest_report_post() - { - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->add_lang('mcp'); - $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); - - $this->set_reporting_guest(1); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - $this->set_reporting_guest(-1); - } - - protected function set_reporting_guest($report_post_allowed) - { - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid); - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - $values["group_id[0]"] = 1; - $form->setValues($values); - $crawler = self::submit($form); - - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - $values["forum_id"] = 2; - $form->setValues($values); - $crawler = self::submit($form); - - $this->add_lang('acp/permissions'); - $form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form(); - $values = $form->getValues(); - $values["setting[1][2][f_report]"] = $report_post_allowed; - $form->setValues($values); - $crawler = self::submit($form); - - $crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid); - } -} diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php new file mode 100644 index 0000000000..8283465041 --- /dev/null +++ b/tests/functional/report_post_captcha_test.php @@ -0,0 +1,66 @@ +add_lang('mcp'); + $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); + + $this->set_reporting_guest(1); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + $this->set_reporting_guest(-1); + } + + public function test_user_report_post() + { + $this->login(); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); + } + + protected function set_reporting_guest($report_post_allowed) + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values["group_id[0]"] = 1; + $form->setValues($values); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values["forum_id"] = 2; + $form->setValues($values); + $crawler = self::submit($form); + + $this->add_lang('acp/permissions'); + $form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form(); + $values = $form->getValues(); + $values["setting[1][2][f_report]"] = $report_post_allowed; + $form->setValues($values); + $crawler = self::submit($form); + + $crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid); + } +} -- cgit v1.2.1 From 2eb32ef515c59b19bd1bb4f7e6d56736733ea9d8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Jul 2013 13:38:19 +0200 Subject: [ticket/11531] Check if uploaded avatar is properly displayed in tests PHPBB3-11531 --- tests/functional/avatar_ucp_users_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php index fa6282abf4..f828559e0d 100644 --- a/tests/functional/avatar_ucp_users_test.php +++ b/tests/functional/avatar_ucp_users_test.php @@ -59,4 +59,20 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava { $this->assert_avatar_submit($expected, $avatar_type, $data); } + + public function test_display_upload_avatar() + { + $this->assert_avatar_submit('PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ) + ); + + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + $avatar_link = $crawler->filter('img')->attr('src'); + $crawler = self::request('GET', $avatar_link . '&sid=' . $this->sid, array(), false); + $content = self::$client->getResponse()->getContent(); + self::assertEquals(false, stripos(trim($content), 'debug'), 'Output contains debug message'); + } } -- cgit v1.2.1