mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-30 02:59:29 +02:00
[ticket/11587] Add functional tests for group teampage settings
The group_legend and group_teampage settings, which are needed for the teampage, are tested with these newly added functional tests. Duplicate code has been reduced as much as possible. PHPBB3-11587
This commit is contained in:
parent
0aa964786d
commit
495b22632c
@ -14,8 +14,107 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
|
||||
*/
|
||||
class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test
|
||||
{
|
||||
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 = $this->client->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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,30 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
|
||||
{
|
||||
abstract protected function get_url();
|
||||
|
||||
/**
|
||||
* Get group_manage form
|
||||
* @param int $group_id ID of the group that should be managed
|
||||
*/
|
||||
protected function get_group_manage_form($group_id = 5)
|
||||
{
|
||||
// Manage Administrators group
|
||||
$crawler = $this->request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
|
||||
$this->assert_response_success();
|
||||
//var_export($this->client->getResponse()->getContent());
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute login calls and add_lang() calls for tests
|
||||
*/
|
||||
protected function group_manage_login()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang(array('ucp', 'acp/groups'));
|
||||
}
|
||||
|
||||
public function groups_manage_test_data()
|
||||
{
|
||||
return array(
|
||||
@ -30,14 +54,10 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
|
||||
*/
|
||||
public function test_groups_manage($input, $expected)
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang(array('ucp', 'acp/groups'));
|
||||
$this->group_manage_login();
|
||||
|
||||
// Manage Administrators group
|
||||
$crawler = $this->request('GET', $this->get_url() . '&g=5&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$form = $this->get_group_manage_form();
|
||||
$form['group_colour']->setValue($input);
|
||||
$crawler = $this->client->submit($form);
|
||||
$this->assertContains($this->lang($expected), $crawler->text());
|
||||
|
@ -14,8 +14,40 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
|
||||
*/
|
||||
class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test
|
||||
{
|
||||
protected $db;
|
||||
|
||||
protected function get_url()
|
||||
{
|
||||
return 'ucp.php?i=groups&mode=manage&action=edit';
|
||||
}
|
||||
|
||||
protected function get_teampage_settings()
|
||||
{
|
||||
if (!isset($this->db))
|
||||
{
|
||||
$this->db = $this->get_db();
|
||||
}
|
||||
$sql = 'SELECT g.group_legend AS group_legend, t.teampage_position AS group_teampage
|
||||
FROM ' . GROUPS_TABLE . ' g
|
||||
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
|
||||
ON (t.group_id = g.group_id)
|
||||
WHERE g.group_id = 5';
|
||||
$result = $this->db->sql_query($sql);
|
||||
$group_row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
return $group_row;
|
||||
}
|
||||
|
||||
public function test_ucp_groups_teampage()
|
||||
{
|
||||
$this->group_manage_login();
|
||||
|
||||
// Test if group_legend or group_teampage are modified while
|
||||
// submitting the ucp_group_manage page
|
||||
$form = $this->get_group_manage_form();
|
||||
$teampage_settings = $this->get_teampage_settings();
|
||||
$crawler = $this->client->submit($form);
|
||||
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
|
||||
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user