Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 53 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_ucp_groups_test | |
0.00% |
0 / 53 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| get_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_teampage_settings | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| test_ucp_groups_teampage | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_create_request_group | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| test_request_group_membership | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| test_approve_group_membership | |
0.00% |
0 / 10 |
|
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_ucp_groups_test extends phpbb_functional_common_groups_test_case |
| 20 | { |
| 21 | protected function get_url() |
| 22 | { |
| 23 | return 'ucp.php?i=groups&mode=manage&action=edit'; |
| 24 | } |
| 25 | |
| 26 | protected function get_teampage_settings() |
| 27 | { |
| 28 | $sql = 'SELECT g.group_legend AS group_legend, t.teampage_position AS group_teampage |
| 29 | FROM ' . GROUPS_TABLE . ' g |
| 30 | LEFT JOIN ' . TEAMPAGE_TABLE . ' t |
| 31 | ON (t.group_id = g.group_id) |
| 32 | WHERE g.group_id = 5'; |
| 33 | $result = $this->db->sql_query($sql); |
| 34 | $group_row = $this->db->sql_fetchrow($result); |
| 35 | $this->db->sql_freeresult($result); |
| 36 | return $group_row; |
| 37 | } |
| 38 | |
| 39 | public function test_ucp_groups_teampage() |
| 40 | { |
| 41 | $this->group_manage_login(); |
| 42 | |
| 43 | // Test if group_legend or group_teampage are modified while |
| 44 | // submitting the ucp_group_manage page |
| 45 | $form = $this->get_group_manage_form(); |
| 46 | $teampage_settings = $this->get_teampage_settings(); |
| 47 | $crawler = self::submit($form); |
| 48 | $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text()); |
| 49 | $this->assertEquals($teampage_settings, $this->get_teampage_settings()); |
| 50 | } |
| 51 | |
| 52 | public function test_create_request_group() |
| 53 | { |
| 54 | $this->login(); |
| 55 | $this->admin_login(); |
| 56 | $this->add_lang('acp/groups'); |
| 57 | |
| 58 | $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid); |
| 59 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); |
| 60 | $crawler = self::submit($form, array('group_name' => 'request-group')); |
| 61 | |
| 62 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); |
| 63 | $crawler = self::submit($form, array('group_name' => 'request-group')); |
| 64 | |
| 65 | $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text()); |
| 66 | |
| 67 | $group_id = $this->get_group_id('request-group'); |
| 68 | |
| 69 | // Make admin group leader |
| 70 | $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid); |
| 71 | $form = $crawler->filter('input[name=addusers]')->selectButton($this->lang('SUBMIT'))->form(); |
| 72 | $crawler = self::submit($form, [ |
| 73 | 'leader' => 1, |
| 74 | 'usernames' => 'admin', |
| 75 | ]); |
| 76 | |
| 77 | $this->assertContainsLang('GROUP_MODS_ADDED', $crawler->filter('#main')->text()); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @depends test_create_request_group |
| 82 | */ |
| 83 | public function test_request_group_membership() |
| 84 | { |
| 85 | $this->create_user('request-group-user'); |
| 86 | $this->login('request-group-user'); |
| 87 | $this->add_lang('groups'); |
| 88 | |
| 89 | $group_id = $this->get_group_id('request-group'); |
| 90 | |
| 91 | $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=membership&sid=' . $this->sid); |
| 92 | $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); |
| 93 | $crawler = self::submit($form, ['selected' => $group_id, 'action' => 'join']); |
| 94 | $this->assertContainsLang('GROUP_JOIN_PENDING_CONFIRM', $crawler->text()); |
| 95 | |
| 96 | $form = $crawler->selectButton($this->lang('YES'))->form(); |
| 97 | $crawler = self::submit($form); |
| 98 | $this->assertContainsLang('GROUP_JOINED_PENDING', $crawler->text()); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @depends test_request_group_membership |
| 103 | */ |
| 104 | public function test_approve_group_membership() |
| 105 | { |
| 106 | $this->login(); |
| 107 | $this->add_lang('acp/groups'); |
| 108 | |
| 109 | $group_id = $this->get_group_id('request-group'); |
| 110 | $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid); |
| 111 | $form = $crawler->filter('input[name=update]')->selectButton($this->lang('SUBMIT'))->form(); |
| 112 | $crawler = self::submit($form, [ |
| 113 | 'mark' => [$crawler->filter('input[name="mark[]"]')->first()->attr('value')], |
| 114 | 'action' => 'approve', |
| 115 | ]); |
| 116 | |
| 117 | $this->assertContainsLang('USERS_APPROVED', $crawler->text()); |
| 118 | } |
| 119 | } |