aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-03-01 16:57:00 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-03-01 16:57:00 -0500
commit448df1cdf5d06e9457397ae439c04ad44084c2a9 (patch)
treee69a986e6910157ff8c1d1b51a267494e263c053 /tests
parent6c49f95b01c812144b16fdea74cc0841f354e810 (diff)
parent4ac8eaf9e3421f394136dc722542198b3048f4f8 (diff)
downloadforums-448df1cdf5d06e9457397ae439c04ad44084c2a9.tar
forums-448df1cdf5d06e9457397ae439c04ad44084c2a9.tar.gz
forums-448df1cdf5d06e9457397ae439c04ad44084c2a9.tar.bz2
forums-448df1cdf5d06e9457397ae439c04ad44084c2a9.tar.xz
forums-448df1cdf5d06e9457397ae439c04ad44084c2a9.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/group_positions/fixtures/group_positions.xml23
-rw-r--r--tests/group_positions/group_positions_test.php287
2 files changed, 310 insertions, 0 deletions
diff --git a/tests/group_positions/fixtures/group_positions.xml b/tests/group_positions/fixtures/group_positions.xml
new file mode 100644
index 0000000000..55b1c2e08d
--- /dev/null
+++ b/tests/group_positions/fixtures/group_positions.xml
@@ -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>
diff --git a/tests/group_positions/group_positions_test.php b/tests/group_positions/group_positions_test.php
new file mode 100644
index 0000000000..b68f205b37
--- /dev/null
+++ b/tests/group_positions/group_positions_test.php
@@ -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));
+ }
+}
+