diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2013-05-13 11:57:41 +0200 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2013-05-13 11:57:41 +0200 |
| commit | 9c4d8b3193ca853d67c0098e1627db17f7dd0311 (patch) | |
| tree | 0c1531517ba6c1e2d8558c24a5839f4f1acd8378 | |
| parent | 0a707dd1ceec36b53ea45889b27051ed8a9a4e4b (diff) | |
| download | forums-9c4d8b3193ca853d67c0098e1627db17f7dd0311.tar forums-9c4d8b3193ca853d67c0098e1627db17f7dd0311.tar.gz forums-9c4d8b3193ca853d67c0098e1627db17f7dd0311.tar.bz2 forums-9c4d8b3193ca853d67c0098e1627db17f7dd0311.tar.xz forums-9c4d8b3193ca853d67c0098e1627db17f7dd0311.zip | |
[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
| -rw-r--r-- | tests/functional/avatar_acp_test.php | 147 | ||||
| -rw-r--r-- | tests/functional/avatar_test.php | 46 |
2 files changed, 192 insertions, 1 deletions
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 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +/** + * @group functional + */ +class phpbb_functional_avatar_acp_test extends phpbb_functional_test_case +{ + private $path; + private $form_content; + + public function setUp() + { + parent::setUp(); + $this->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()); + } } |
