From 50542a389cfb6189334ed704c1d5c984f3ddf76b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Jan 2013 14:35:37 +0100 Subject: [ticket/9492] Add unit tests for custom ranks and avatars PHPBB3-9492 --- .../functions_user/group_user_attributes_test.php | 149 +++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 tests/functions_user/group_user_attributes_test.php (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php new file mode 100644 index 0000000000..35d0b9e348 --- /dev/null +++ b/tests/functions_user/group_user_attributes_test.php @@ -0,0 +1,149 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/group_user_attributes.xml'); + } + + public function group_user_attributes_data() + { + return array( + array( + 'Setting new default group without settings for user with no settings - no change', + 1, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => '', + 'user_rank' => 0, + ), + ), + array( + 'Setting new default group without settings for user with default settings - user settings overwritten', + 2, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => '', + 'user_rank' => 0, + ), + ), + array( + 'Setting new default group without settings for user with custom settings - no change', + 3, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => 'custom', + 'user_rank' => 2, + ), + ), + array( + 'Setting new default group with settings for user with no settings - user settings overwritten', + 1, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'default2', + 'user_rank' => 3, + ), + ), + array( + 'Setting new default group with settings for user with default settings - user settings overwritten', + 2, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'default2', + 'user_rank' => 3, + ), + ), + array( + 'Setting new default group with settings for user with custom settings - no change', + 3, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'custom', + 'user_rank' => 2, + ), + ), + ); + } + + /** + * @dataProvider group_user_attributes_data + */ + public function test_group_user_attributes($description, $user_id, $group_id, $group_row, $expected) + { + global $auth, $cache, $db, $phpbb_dispatcher, $user; + + $user->ip = ''; + $cache = new phpbb_mock_cache; + $db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $auth = $this->getMock('phpbb_auth'); + $auth->expects($this->any()) + ->method('acl_clear_prefetch'); + + group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); + + $sql = 'SELECT user_avatar, user_rank + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + + $this->assertEquals(array($expected), $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } +} -- cgit v1.2.1 From ddec4e00d54c3c6e409cdf005442d36ccd9cf120 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Jan 2013 20:59:27 +0100 Subject: [ticket/9492] Fix missing phpbb_container in unit tests PHPBB3-9492 --- tests/functions_user/group_user_attributes_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 35d0b9e348..f13156c2cc 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -125,7 +125,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes */ public function test_group_user_attributes($description, $user_id, $group_id, $group_row, $expected) { - global $auth, $cache, $db, $phpbb_dispatcher, $user; + global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container; $user->ip = ''; $cache = new phpbb_mock_cache; @@ -134,6 +134,13 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) ->method('acl_clear_prefetch'); + $cache_driver = new phpbb_cache_driver_null(); + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container + ->expects($this->any()) + ->method('get') + ->with('cache.driver') + ->will($this->returnValue($cache_driver)); group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); -- cgit v1.2.1 From e8fd8b9a4b37f7d7d3955cd2b0d79139a2c0222d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 22 Jan 2013 22:40:53 +0100 Subject: [ticket/10714] Fix missing parameter and global phpbb_log in unit tests PHPBB3-10714 --- tests/functions_user/group_user_attributes_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f13156c2cc..4336fd894e 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -125,7 +125,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes */ public function test_group_user_attributes($description, $user_id, $group_id, $group_row, $expected) { - global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container; + global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container, $phpbb_log, $phpbb_root_path, $phpEx; $user->ip = ''; $cache = new phpbb_mock_cache; @@ -141,6 +141,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes ->method('get') ->with('cache.driver') ->will($this->returnValue($cache_driver)); + $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- tests/functions_user/group_user_attributes_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 4336fd894e..f8d52a9a6a 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -131,17 +131,17 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_clear_prefetch'); - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) ->method('get') ->with('cache.driver') ->will($this->returnValue($cache_driver)); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); -- cgit v1.2.1 From 1f624e136785893d0c9e4bfeb1a12f9c08693a24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 21:41:41 +0200 Subject: [ticket/11842] Replace outdated occurences of user and group avatar_type user_avatar_type und group_avatar_type are now a string and should therefore be treated accordingly. PHPBB3-11842 --- tests/functions_user/group_user_attributes_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f8d52a9a6a..5ed60f6593 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -27,7 +27,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -43,7 +43,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -59,7 +59,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -75,7 +75,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, @@ -91,7 +91,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, @@ -107,7 +107,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, -- cgit v1.2.1 From 3a03b01ce0b860490851c620a6c4dac2630481d4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 14:22:33 +0100 Subject: [ticket/12056] group_user_attributes: Fix "Creating ... from empty value". PHPBB3-12056 --- tests/functions_user/group_user_attributes_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f8d52a9a6a..4317cf79da 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -127,6 +127,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes { global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container, $phpbb_log, $phpbb_root_path, $phpEx; + $user = new phpbb_mock_user; $user->ip = ''; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- tests/functions_user/group_user_attributes_test.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/functions_user/group_user_attributes_test.php') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 86e4767970..99a15b32bf 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1