Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_common_avatar_test_case | |
0.00% |
0 / 33 |
|
0.00% |
0 / 3 |
72 | |
0.00% |
0 / 1 |
| get_url | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| setUp | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| set_acp_settings | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| assert_avatar_submit | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
42 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @group functional |
| 16 | */ |
| 17 | abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional_test_case |
| 18 | { |
| 19 | private $path; |
| 20 | |
| 21 | abstract function get_url(); |
| 22 | |
| 23 | protected function setUp(): void |
| 24 | { |
| 25 | parent::setUp(); |
| 26 | $this->path = __DIR__ . '/fixtures/files/'; |
| 27 | $this->login(); |
| 28 | $this->admin_login(); |
| 29 | $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); |
| 30 | $this->set_acp_settings(); |
| 31 | } |
| 32 | |
| 33 | private function set_acp_settings() |
| 34 | { |
| 35 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); |
| 36 | // Check the default entries we should have |
| 37 | $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); |
| 38 | $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); |
| 39 | $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); |
| 40 | |
| 41 | // Now start setting the needed settings |
| 42 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); |
| 43 | $form['config[allow_avatar_local]']->select(1); |
| 44 | $form['config[allow_avatar_gravatar]']->select(1); |
| 45 | $crawler = self::submit($form); |
| 46 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); |
| 47 | } |
| 48 | |
| 49 | public function assert_avatar_submit($expected, $type, $data, $delete = false, $button_text = 'SUBMIT') |
| 50 | { |
| 51 | $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); |
| 52 | |
| 53 | // Test if setting a gravatar avatar properly works |
| 54 | $form = $crawler->selectButton($this->lang($button_text))->form(); |
| 55 | $form['avatar_driver']->select($type); |
| 56 | |
| 57 | foreach ($data as $key => $value) |
| 58 | { |
| 59 | if (is_array($value)) |
| 60 | { |
| 61 | $form[$key]->{$value[0]}($value[1]); |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | $form[$key]->setValue($value); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | $crawler = self::submit($form); |
| 70 | |
| 71 | if (is_array($expected)) |
| 72 | { |
| 73 | $delete_expected = $expected[1]; |
| 74 | $expected = $expected[0]; |
| 75 | } |
| 76 | |
| 77 | try |
| 78 | { |
| 79 | $this->assertContainsLang($expected, $crawler->text()); |
| 80 | } |
| 81 | catch (Exception $e) |
| 82 | { |
| 83 | $this->assertStringContainsString($expected, $crawler->text()); |
| 84 | } |
| 85 | |
| 86 | if ($delete) |
| 87 | { |
| 88 | $form = $crawler->selectButton('confirm')->form(); |
| 89 | $crawler = self::submit($form); |
| 90 | $this->assertContainsLang($delete_expected, $crawler->text()); |
| 91 | } |
| 92 | } |
| 93 | } |