Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 72 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_acp_groups_test | |
0.00% |
0 / 72 |
|
0.00% |
0 / 4 |
110 | |
0.00% |
0 / 1 |
| get_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| acp_group_test_data | |
0.00% |
0 / 42 |
|
0.00% |
0 / 1 |
2 | |||
| test_acp_groups_teampage | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
56 | |||
| test_acp_groups_create_existing_name | |
0.00% |
0 / 9 |
|
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 | require_once __DIR__ . '/common_groups_test_case.php'; |
| 15 | |
| 16 | /** |
| 17 | * @group functional |
| 18 | */ |
| 19 | class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test_case |
| 20 | { |
| 21 | protected $form_data; |
| 22 | |
| 23 | protected function get_url() |
| 24 | { |
| 25 | return 'adm/index.php?i=groups&mode=manage&action=edit'; |
| 26 | } |
| 27 | |
| 28 | public static function acp_group_test_data() |
| 29 | { |
| 30 | return array( |
| 31 | 'both_yes' => array( |
| 32 | 5, |
| 33 | true, |
| 34 | true, |
| 35 | ), |
| 36 | 'legend_no_teampage' => array( |
| 37 | 5, |
| 38 | true, |
| 39 | false, |
| 40 | ), |
| 41 | 'no_legend_teampage' => array( |
| 42 | 5, |
| 43 | false, |
| 44 | true, |
| 45 | ), |
| 46 | 'both_no' => array( |
| 47 | 5, |
| 48 | false, |
| 49 | false, |
| 50 | ), |
| 51 | 'no_change' => array( |
| 52 | 5, |
| 53 | NULL, |
| 54 | NULL, |
| 55 | ), |
| 56 | 'back_to_default' => array( |
| 57 | 5, |
| 58 | true, |
| 59 | true, |
| 60 | ), |
| 61 | // Remove and add moderators back in order to reset |
| 62 | // group order to default one |
| 63 | 'mods_both_no' => array( |
| 64 | 4, |
| 65 | false, |
| 66 | false, |
| 67 | ), |
| 68 | 'mods_back_to_default' => array( |
| 69 | 4, |
| 70 | true, |
| 71 | true, |
| 72 | ), |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @dataProvider acp_group_test_data |
| 78 | */ |
| 79 | public function test_acp_groups_teampage($group_id, $tick_legend, $tick_teampage) |
| 80 | { |
| 81 | $this->group_manage_login(); |
| 82 | |
| 83 | // Manage Administrators group |
| 84 | $form = $this->get_group_manage_form($group_id); |
| 85 | $this->form_data[0] = $form->getValues(); |
| 86 | |
| 87 | if (isset($tick_legend) && isset($tick_teampage)) |
| 88 | { |
| 89 | if ($tick_legend) |
| 90 | { |
| 91 | $form['group_legend']->tick(); |
| 92 | } |
| 93 | else |
| 94 | { |
| 95 | $form['group_legend']->untick(); |
| 96 | } |
| 97 | |
| 98 | if ($tick_teampage) |
| 99 | { |
| 100 | $form['group_teampage']->tick(); |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | $form['group_teampage']->untick(); |
| 105 | } |
| 106 | } |
| 107 | $crawler = self::submit($form); |
| 108 | $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text()); |
| 109 | |
| 110 | $form = $this->get_group_manage_form($group_id); |
| 111 | if (!isset($tick_legend) && !isset($tick_teampage)) |
| 112 | { |
| 113 | $this->form_data[1] = $form->getValues(); |
| 114 | unset($this->form_data[0]['creation_time'], $this->form_data[0]['form_token'], $this->form_data[1]['creation_time'], $this->form_data[1]['form_token']); |
| 115 | $this->assertEquals($this->form_data[0], $this->form_data[1]); |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | $this->form_data = $form->getValues(); |
| 120 | // form_data[] values can be bool or null if not ticked, $tick_* value can be bool or null if not set. |
| 121 | // Cast both to the same type to correctly compare the values. |
| 122 | $this->assertEquals((bool) $tick_legend, (bool) ($this->form_data['group_legend'] ?? false)); |
| 123 | $this->assertEquals((bool) $tick_teampage, (bool) ($this->form_data['group_teampage'] ?? false)); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | public function test_acp_groups_create_existing_name() |
| 128 | { |
| 129 | $this->group_manage_login(); |
| 130 | |
| 131 | $crawler = self::request('GET', 'adm/index.php?i=groups&mode=manage&sid=' . $this->sid); |
| 132 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form([ |
| 133 | 'group_name' => 'Guests', // 'Guests' is the group name already in use for predefined Guests group |
| 134 | ]); |
| 135 | |
| 136 | $crawler = self::submit($form); |
| 137 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); |
| 138 | $crawler = self::submit($form); // Just submit the form with selected group name |
| 139 | |
| 140 | $this->assertStringContainsString($this->lang('GROUP_NAME_TAKEN'), $crawler->text()); |
| 141 | } |
| 142 | } |