Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 76 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_browse_disabled_test | |
0.00% |
0 / 76 |
|
0.00% |
0 / 5 |
110 | |
0.00% |
0 / 1 |
| setUp | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| tearDown | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| test_disabled_index_admin | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 | |||
| test_disabled_index_global_moderator | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
12 | |||
| test_disabled_index_local_moderator | |
0.00% |
0 / 27 |
|
0.00% |
0 / 1 |
12 | |||
| 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_browse_disabled_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | public function setUp(): void |
| 20 | { |
| 21 | parent::setUp(); |
| 22 | |
| 23 | $this->login(); |
| 24 | $this->admin_login(); |
| 25 | |
| 26 | // Disable board |
| 27 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=settings&sid=' . $this->sid); |
| 28 | $form = $crawler->selectButton('Submit')->form(); |
| 29 | $form->setValues(['config[board_disable]' => 1]); |
| 30 | |
| 31 | $crawler = self::submit($form); |
| 32 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 33 | |
| 34 | $this->logout(); |
| 35 | } |
| 36 | |
| 37 | public function tearDown(): void |
| 38 | { |
| 39 | $this->login(); |
| 40 | $this->admin_login(); |
| 41 | |
| 42 | // Disable board |
| 43 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=settings&sid=' . $this->sid); |
| 44 | $form = $crawler->selectButton('Submit')->form(); |
| 45 | $form->setValues(['config[board_disable]' => 0]); |
| 46 | |
| 47 | $crawler = self::submit($form); |
| 48 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 49 | |
| 50 | $this->logout(); |
| 51 | |
| 52 | parent::tearDown(); |
| 53 | } |
| 54 | |
| 55 | public function test_disabled_index_admin() |
| 56 | { |
| 57 | $this->login(); |
| 58 | $this->admin_login(); |
| 59 | |
| 60 | // Board should be fully visible for all variations for admins |
| 61 | for ($i = 0; $i <= 2; $i++) |
| 62 | { |
| 63 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=settings&sid=' . $this->sid); |
| 64 | $form = $crawler->selectButton('Submit')->form(); |
| 65 | $form->setValues(['config[board_disable_access]' => $i]); |
| 66 | |
| 67 | $crawler = self::submit($form); |
| 68 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 69 | |
| 70 | $crawler = self::request('GET', 'index.php'); |
| 71 | $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); |
| 72 | $this->assertContainsLang('BOARD_DISABLED', $crawler->filter('div[class="rules"]')->text()); |
| 73 | } |
| 74 | |
| 75 | $this->logout(); |
| 76 | } |
| 77 | |
| 78 | public function test_disabled_index_global_moderator() |
| 79 | { |
| 80 | $this->create_user('moderator-disabled-index'); |
| 81 | $this->add_user_group('GLOBAL_MODERATORS', ['moderator-disabled-index']); |
| 82 | |
| 83 | // Board should be fully visible for options 1 & 2 |
| 84 | for ($i = 0; $i <= 2; $i++) |
| 85 | { |
| 86 | $this->login(); |
| 87 | $this->admin_login(); |
| 88 | |
| 89 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=settings&sid=' . $this->sid); |
| 90 | $form = $crawler->selectButton('Submit')->form(); |
| 91 | $form->setValues(['config[board_disable_access]' => $i]); |
| 92 | |
| 93 | $crawler = self::submit($form); |
| 94 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 95 | |
| 96 | $this->logout(); |
| 97 | |
| 98 | $this->login('moderator-disabled-index'); |
| 99 | |
| 100 | $crawler = self::request('GET', 'index.php'); |
| 101 | |
| 102 | if ($i == 0) |
| 103 | { |
| 104 | $this->assertEquals(0, $crawler->filter('.topiclist')->count(), 'Board should not be visible for option ' . $i); |
| 105 | $this->assertContainsLang('BOARD_DISABLE', $crawler->filter('div#message')->text()); |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count(), 'Board should be visible for option ' . $i); |
| 110 | $this->assertContainsLang('BOARD_DISABLED', $crawler->filter('div[class="rules"]')->text()); |
| 111 | } |
| 112 | $this->logout(); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | public function test_disabled_index_local_moderator() |
| 117 | { |
| 118 | $user_id = $this->create_user('moduser-disabled-index'); |
| 119 | |
| 120 | // Set m_delete to yes for user --> user has moderator permission |
| 121 | $this->add_lang('acp/permissions'); |
| 122 | $this->login(); |
| 123 | $this->admin_login(); |
| 124 | $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=setting_user_local&user_id[0]=$user_id&forum_id[0]=2&type=m_&sid={$this->sid}"); |
| 125 | $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); |
| 126 | $data = array("setting[$user_id][2][m_edit]" => ACL_YES); |
| 127 | $form->setValues($data); |
| 128 | self::submit($form); |
| 129 | $this->logout(); |
| 130 | |
| 131 | // Board should be fully visible for option 2 only |
| 132 | for ($i = 0; $i <= 2; $i++) |
| 133 | { |
| 134 | $this->login(); |
| 135 | $this->admin_login(); |
| 136 | |
| 137 | $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=settings&sid=' . $this->sid); |
| 138 | $form = $crawler->selectButton('Submit')->form(); |
| 139 | $form->setValues(['config[board_disable_access]' => $i]); |
| 140 | |
| 141 | $crawler = self::submit($form); |
| 142 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 143 | |
| 144 | $this->logout(); |
| 145 | |
| 146 | $this->login('moduser-disabled-index'); |
| 147 | |
| 148 | $crawler = self::request('GET', 'index.php'); |
| 149 | |
| 150 | if ($i < 2) |
| 151 | { |
| 152 | $this->assertEquals(0, $crawler->filter('.topiclist')->count(), 'Board should not be visible for option ' . $i); |
| 153 | $this->assertContainsLang('BOARD_DISABLE', $crawler->filter('div#message')->text()); |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count(), 'Board should be visible for option ' . $i); |
| 158 | $this->assertContainsLang('BOARD_DISABLED', $crawler->filter('div[class="rules"]')->text()); |
| 159 | } |
| 160 | $this->logout(); |
| 161 | } |
| 162 | } |
| 163 | } |