diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2013-07-17 23:55:20 +0200 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2013-07-17 23:55:20 +0200 |
| commit | 96989e536dd5fc603f3598fa7a2a50414331d76c (patch) | |
| tree | 2c6f33516cb784ba9a9f37a4588e68d1c6f559a9 /tests/functional/common_avatar_test.php | |
| parent | bc6122b64ffb5c13c26991f78346fdc7dee6f9f0 (diff) | |
| download | forums-96989e536dd5fc603f3598fa7a2a50414331d76c.tar forums-96989e536dd5fc603f3598fa7a2a50414331d76c.tar.gz forums-96989e536dd5fc603f3598fa7a2a50414331d76c.tar.bz2 forums-96989e536dd5fc603f3598fa7a2a50414331d76c.tar.xz forums-96989e536dd5fc603f3598fa7a2a50414331d76c.zip | |
[ticket/11531] Use abstract class for avatar tests and unify test cases
PHPBB3-11531
Diffstat (limited to 'tests/functional/common_avatar_test.php')
| -rw-r--r-- | tests/functional/common_avatar_test.php | 80 |
1 files changed, 80 insertions, 0 deletions
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 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +/** + * @group functional + */ +abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test_case +{ + private $path; + private $form_content; + + abstract function get_url(); + + 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')); + $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()); + } + } +} |
