mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge branch 'ticket/9549' into develop
* ticket/9549: [ticket/9549] Display users in their primary group instead of their first group [ticket/9549] Change default value of "sort legend by group name" to false. [ticket/9549] Fix displaying empty groups [ticket/9549] Fix language strings. [ticket/9549] Only add group to legend/teampage when the checkbox is checked. [ticket/9549] New method move() to move a group more than 1 up/down. [ticket/9549] Fix some minor issues with descriptions and coding-guidelines. [ticket/9549] Throw an error when the given field-name is invalid. [ticket/9549] Make the class non static and extend delete_group function. [ticket/9549] Add template changes for subsilver2. [ticket/9549] Enhance teampage and legend functionality [ticket/9549] Add the module and files for the ACP. [ticket/9549] Update database with the new config values and columns [ticket/9549] Enhance teampage functionality with a new class, group_positions. Conflicts: phpBB/install/database_update.php
This commit is contained in:
23
tests/group_positions/fixtures/group_positions.xml
Normal file
23
tests/group_positions/fixtures/group_positions.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_groups">
|
||||
<column>group_id</column>
|
||||
<column>group_teampage</column>
|
||||
<column>group_legend</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
287
tests/group_positions/group_positions_test.php
Normal file
287
tests/group_positions/group_positions_test.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class phpbb_group_positions_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/group_positions.xml');
|
||||
}
|
||||
|
||||
public static function get_group_value_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, 0),
|
||||
array('teampage', 2, 1),
|
||||
array('legend', 1, 0),
|
||||
array('legend', 3, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_group_value_data
|
||||
*/
|
||||
public function test_get_group_value($field, $group_id, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$this->assertEquals($expected, $test_class->get_group_value($group_id));
|
||||
}
|
||||
|
||||
public static function get_group_count_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 2),
|
||||
array('legend', 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_group_count_data
|
||||
*/
|
||||
public function test_get_group_count($field, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$this->assertEquals($expected, $test_class->get_group_count());
|
||||
}
|
||||
|
||||
public static function add_group_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 3, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider add_group_data
|
||||
*/
|
||||
public function test_add_group($field, $group_id, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$test_class->add_group($group_id);
|
||||
|
||||
$result = $db->sql_query('SELECT group_id, group_teampage, group_legend
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
|
||||
public static function delete_group_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, false, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, false, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, false, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 0, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 1, true, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, true, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, true, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider delete_group_data
|
||||
*/
|
||||
public function test_delete_group($field, $group_id, $skip_group, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$test_class->delete_group($group_id, $skip_group);
|
||||
|
||||
$result = $db->sql_query('SELECT group_id, group_teampage, group_legend
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
|
||||
public static function move_up_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider move_up_data
|
||||
*/
|
||||
public function test_move_up($field, $group_id, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$test_class->move_up($group_id);
|
||||
|
||||
$result = $db->sql_query('SELECT group_id, group_teampage, group_legend
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
|
||||
public static function move_down_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider move_down_data
|
||||
*/
|
||||
public function test_move_down($field, $group_id, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$test_class->move_down($group_id);
|
||||
|
||||
$result = $db->sql_query('SELECT group_id, group_teampage, group_legend
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
|
||||
public static function move_data()
|
||||
{
|
||||
return array(
|
||||
array('teampage', 1, 1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 1, -1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, 3, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, 0, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, -1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 2, -3, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1),
|
||||
)),
|
||||
array('teampage', 3, -1, array(
|
||||
array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0),
|
||||
array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0),
|
||||
array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider move_data
|
||||
*/
|
||||
public function test_move($field, $group_id, $increment, $expected)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$test_class = new phpbb_group_positions($db, $field);
|
||||
$test_class->move($group_id, $increment);
|
||||
|
||||
$result = $db->sql_query('SELECT group_id, group_teampage, group_legend
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user