Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 58 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_ucp_preferences_test | |
0.00% |
0 / 58 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| test_submitting_preferences_view | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |||
| test_submitting_invalid_preferences_view | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
6 | |||
| test_read_preferences_view | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| test_reset_preferences_default | |
0.00% |
0 / 14 |
|
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_ucp_preferences_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | public function test_submitting_preferences_view() |
| 20 | { |
| 21 | $this->add_lang('ucp'); |
| 22 | $this->login(); |
| 23 | |
| 24 | $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); |
| 25 | $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); |
| 26 | |
| 27 | $form = $crawler->selectButton('Submit')->form(array( |
| 28 | 'topic_sk' => 'a', |
| 29 | 'topic_sd' => 'a', |
| 30 | 'topic_st' => '1', |
| 31 | 'post_sk' => 'a', |
| 32 | 'post_sd' => 'a', |
| 33 | 'post_st' => '1', |
| 34 | )); |
| 35 | |
| 36 | $crawler = self::submit($form); |
| 37 | $this->assertContainsLang('PREFERENCES_UPDATED', $crawler->filter('#message')->text()); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @depends test_submitting_preferences_view |
| 42 | */ |
| 43 | public function test_submitting_invalid_preferences_view() |
| 44 | { |
| 45 | $this->add_lang('ucp'); |
| 46 | $this->login(); |
| 47 | |
| 48 | $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); |
| 49 | $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); |
| 50 | $form = $crawler->selectButton('Submit')->form(); |
| 51 | |
| 52 | if (!method_exists($form, 'disableValidation')) |
| 53 | { |
| 54 | $this->markTestIncomplete('The crawler cannot select invalid values, until Symfony 2.4!'); |
| 55 | } |
| 56 | |
| 57 | $form = $form->disableValidation(); |
| 58 | $form['topic_sk']->select('z'); |
| 59 | $form['topic_sd']->select('z'); |
| 60 | $form['topic_st']->select('test'); |
| 61 | $form['post_sk']->select('z'); |
| 62 | $form['post_sd']->select('z'); |
| 63 | $form['post_st']->select('test'); |
| 64 | |
| 65 | $crawler = self::submit($form); |
| 66 | $this->assertContainsLang('WRONG_DATA_POST_SD', $crawler->filter('#cp-main')->text()); |
| 67 | $this->assertContainsLang('WRONG_DATA_POST_SK', $crawler->filter('#cp-main')->text()); |
| 68 | $this->assertContainsLang('WRONG_DATA_TOPIC_SD', $crawler->filter('#cp-main')->text()); |
| 69 | $this->assertContainsLang('WRONG_DATA_TOPIC_SK', $crawler->filter('#cp-main')->text()); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @depends test_submitting_invalid_preferences_view |
| 74 | */ |
| 75 | public function test_read_preferences_view() |
| 76 | { |
| 77 | $this->add_lang('ucp'); |
| 78 | $this->login(); |
| 79 | |
| 80 | $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); |
| 81 | $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); |
| 82 | $form = $crawler->selectButton('Submit')->form(); |
| 83 | |
| 84 | $this->assertEquals('a', $form->get('topic_sk')->getValue()); |
| 85 | $this->assertEquals('a', $form->get('topic_sd')->getValue()); |
| 86 | $this->assertEquals('1', $form->get('topic_st')->getValue()); |
| 87 | $this->assertEquals('a', $form->get('post_sk')->getValue()); |
| 88 | $this->assertEquals('a', $form->get('post_sd')->getValue()); |
| 89 | $this->assertEquals('1', $form->get('post_st')->getValue()); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @depends test_read_preferences_view |
| 94 | */ |
| 95 | public function test_reset_preferences_default() |
| 96 | { |
| 97 | $this->add_lang('ucp'); |
| 98 | $this->login(); |
| 99 | |
| 100 | $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); |
| 101 | $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); |
| 102 | |
| 103 | $form = $crawler->selectButton('Submit')->form(array( |
| 104 | 'topic_sk' => 't', |
| 105 | 'topic_sd' => 'd', |
| 106 | 'topic_st' => '0', |
| 107 | 'post_sk' => 't', |
| 108 | 'post_sd' => 'a', |
| 109 | 'post_st' => '0', |
| 110 | )); |
| 111 | |
| 112 | $crawler = self::submit($form); |
| 113 | $this->assertContainsLang('PREFERENCES_UPDATED', $crawler->filter('#message')->text()); |
| 114 | } |
| 115 | } |