Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_acp_post_settings_test | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| test_allowed_schemes_links | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | class phpbb_functional_acp_post_settings_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | public function test_allowed_schemes_links() |
| 20 | { |
| 21 | $this->add_lang(['acp/common', 'acp/board']); |
| 22 | $this->login(); |
| 23 | $this->admin_login(); |
| 24 | |
| 25 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=post&sid=' . $this->sid); |
| 26 | $this->assertContainsLang('ACP_POST_SETTINGS_EXPLAIN', $this->get_content()); |
| 27 | |
| 28 | // Test trailing comma - invalid |
| 29 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form([ |
| 30 | 'config[allowed_schemes_links]' => 'http,https,ftp,' |
| 31 | ]); |
| 32 | $crawler = self::submit($form); |
| 33 | $this->assertContainsLang('WARNING', $crawler->filter('div[class="errorbox"] > h3')->text()); |
| 34 | $this->assertStringContainsString($this->lang('CSV_INVALID', $this->lang('ALLOWED_SCHEMES_LINKS')), $crawler->filter('div[class="errorbox"] > p')->text()); |
| 35 | |
| 36 | // Test trailing comma and invalid scheme - invalid |
| 37 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form([ |
| 38 | 'config[allowed_schemes_links]' => 'http,https,2ftp,' |
| 39 | ]); |
| 40 | $crawler = self::submit($form); |
| 41 | $this->assertContainsLang('WARNING', $crawler->filter('div[class="errorbox"] > h3')->text()); |
| 42 | $this->assertStringContainsString($this->lang('CSV_INVALID', $this->lang('ALLOWED_SCHEMES_LINKS')), $crawler->filter('div[class="errorbox"] > p')->text()); |
| 43 | $this->assertStringContainsString($this->lang('URL_SCHEME_INVALID', $this->lang('ALLOWED_SCHEMES_LINKS'), '2ftp'), $crawler->filter('div[class="errorbox"] > p')->text()); |
| 44 | |
| 45 | // Test empty setting - valid |
| 46 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form([ |
| 47 | 'config[allowed_schemes_links]' => '' |
| 48 | ]); |
| 49 | $crawler = self::submit($form); |
| 50 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 51 | |
| 52 | // Restore default setting - 'http,https,ftp' |
| 53 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=post&sid=' . $this->sid); |
| 54 | $this->assertContainsLang('ACP_POST_SETTINGS_EXPLAIN', $this->get_content()); |
| 55 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form([ |
| 56 | 'config[allowed_schemes_links]' => 'http,https,ftp' |
| 57 | ]); |
| 58 | $crawler = self::submit($form); |
| 59 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 60 | } |
| 61 | } |