aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/acp_groups_test.php
blob: 9dfdc93474bccf16e8f5282ad2184f601d2015dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

require_once dirname(__FILE__) . '/common_groups_test_case.php';

/**
* @group functional
*/
class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test_case
{
	protected $form_data;

	protected function get_url()
	{
		return 'adm/index.php?i=groups&mode=manage&action=edit';
	}

	public function acp_group_test_data()
	{
		return array(
			'both_yes' => array(
				5,
				true,
				true,
			),
			'legend_no_teampage' => array(
				5,
				true,
				false,
			),
			'no_legend_teampage' => array(
				5,
				false,
				true,
			),
			'both_no' => array(
				5,
				false,
				false,
			),
			'no_change' => array(
				5,
				NULL,
				NULL,
			),
			'back_to_default' => array(
				5,
				true,
				true,
			),
			// Remove and add moderators back in order to reset
			// group order to default one
			'mods_both_no' => array(
				4,
				false,
				false,
			),
			'mods_back_to_default' => array(
				4,
				true,
				true,
			),
		);
	}

	/**
	* @dataProvider acp_group_test_data
	*/
	public function test_acp_groups_teampage($group_id, $tick_legend, $tick_teampage)
	{
		$this->group_manage_login();

		// Manage Administrators group
		$form = $this->get_group_manage_form($group_id);
		$this->form_data[0] = $form->getValues();

		if (isset($tick_legend) && isset($tick_teampage))
		{
			if ($tick_legend)
			{
				$form['group_legend']->tick();
			}
			else
			{
				$form['group_legend']->untick();
			}

			if ($tick_teampage)
			{
				$form['group_teampage']->tick();
			}
			else
			{
				$form['group_teampage']->untick();
			}
		}
		$crawler = self::submit($form);
		$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());

		$form = $this->get_group_manage_form($group_id);
		if (!isset($tick_legend) && !isset($tick_teampage))
		{
			$this->form_data[1] = $form->getValues();
			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']);
			$this->assertEquals($this->form_data[0], $this->form_data[1]);
		}
		else
		{
			$this->form_data = $form->getValues();
			$this->assertEquals($tick_legend, $this->form_data['group_legend']);
			$this->assertEquals($tick_teampage, $this->form_data['group_teampage']);
		}
	}
}