From 9c4d8b3193ca853d67c0098e1627db17f7dd0311 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 13 May 2013 11:57:41 +0200 Subject: [PATCH] [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 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()); + } }