From 057bbfa2406bf659d85d137c07704f0aaddb4478 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 May 2013 15:57:17 +0200 Subject: [PATCH 1/7] [ticket/11543] Add unit tests for obtain_guest_count() PHPBB3-11543 --- tests/functions/fixtures/obtain_online.xml | 11 ++++ tests/functions/obtain_online_test.php | 69 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/functions/fixtures/obtain_online.xml create mode 100644 tests/functions/obtain_online_test.php diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml new file mode 100644 index 0000000000..ea4d6f9238 --- /dev/null +++ b/tests/functions/fixtures/obtain_online.xml @@ -0,0 +1,11 @@ + + + + session_id + session_user_id + session_forum_id + session_time + session_ip + session_viewonline +
+
diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php new file mode 100644 index 0000000000..1089b42616 --- /dev/null +++ b/tests/functions/obtain_online_test.php @@ -0,0 +1,69 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/obtain_online.xml'); + } + + protected function setUp() + { + global $config, $db; + + $db = $this->db = $this->new_dbal(); + $config = array( + 'load_online_time' => 5, + ); + } + + static public function obtain_guest_count_data() + { + return array( + array(0, 2), + array(1, 1), + ); + } + + /** + * @dataProvider obtain_guest_count_data + */ + public function test_obtain_guest_count($forum_id, $expected) + { + $this->db->sql_query('DELETE FROM phpbb_sessions'); + + $this->create_guest_sessions(); + $this->assertEquals($expected, obtain_guest_count($forum_id)); + } + + protected function create_guest_sessions() + { + $this->add_session(1, '0001', 0, true, 0); + $this->add_session(1, '0002', 1, true, 0); + $this->add_session(1, '0003', 0, true, 10); + $this->add_session(1, '0004', 1, true, 10); + } + + protected function add_session($user_id, $user_ip, $forum_id, $view_online, $time_delta) + { + $sql_ary = array( + 'session_id' => $user_id . '_' . $forum_id . '_session00000000000000000' . $user_ip, + 'session_user_id' => $user_id, + 'session_ip' => $user_ip, + 'session_forum_id' => $forum_id, + 'session_time' => time() - $time_delta * 60, + 'session_viewonline' => $view_online, + ); + + $this->db->sql_query('INSERT INTO phpbb_sessions ' . $this->db->sql_build_array('INSERT', $sql_ary)); + } +} From 6b3758edd091f09f46b8117df39c4d104e96739b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 May 2013 15:57:57 +0200 Subject: [PATCH 2/7] [ticket/11543] Add unit tests for obtain_users_online() PHPBB3-11543 --- tests/functions/obtain_online_test.php | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 1089b42616..efb8e97fc7 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -45,6 +45,59 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $this->assertEquals($expected, obtain_guest_count($forum_id)); } + static public function obtain_users_online_data() + { + return array( + array(0, false, array( + 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7), + 'hidden_users' => array(6 => 6, 7 => 7), + 'total_online' => 4, + 'visible_online' => 2, + 'hidden_online' => 2, + 'guests_online' => 0, + )), + array(0, true, array( + 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7), + 'hidden_users' => array(6 => 6, 7 => 7), + 'total_online' => 6, + 'visible_online' => 2, + 'hidden_online' => 2, + 'guests_online' => 2, + )), + array(1, false, array( + 'online_users' => array(3 => 3, 7 => 7), + 'hidden_users' => array(7 => 7), + 'total_online' => 2, + 'visible_online' => 1, + 'hidden_online' => 1, + 'guests_online' => 0, + )), + array(1, true, array( + 'online_users' => array(3 => 3, 7 => 7), + 'hidden_users' => array(7 => 7), + 'total_online' => 3, + 'visible_online' => 1, + 'hidden_online' => 1, + 'guests_online' => 1, + )), + ); + } + + /** + * @dataProvider obtain_users_online_data + */ + public function test_obtain_users_online($forum_id, $display_guests, $expected) + { + $this->db->sql_query('DELETE FROM phpbb_sessions'); + + global $config; + $config['load_online_guests'] = $display_guests; + + $this->create_guest_sessions(); + $this->create_user_sessions(); + $this->assertEquals($expected, obtain_users_online($forum_id)); + } + protected function create_guest_sessions() { $this->add_session(1, '0001', 0, true, 0); @@ -53,6 +106,18 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $this->add_session(1, '0004', 1, true, 10); } + protected function create_user_sessions() + { + $this->add_session(2, '0005', 0, true, 0); + $this->add_session(3, '0006', 1, true, 0); + $this->add_session(4, '0007', 0, true, 10); + $this->add_session(5, '0008', 1, true, 10); + $this->add_session(6, '0005', 0, false, 0); + $this->add_session(7, '0006', 1, false, 0); + $this->add_session(8, '0007', 0, false, 10); + $this->add_session(9, '0008', 1, false, 10); + } + protected function add_session($user_id, $user_ip, $forum_id, $view_online, $time_delta) { $sql_ary = array( From 3301b01f4c659af15393a58b8221d62a906551be Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 May 2013 16:02:30 +0200 Subject: [PATCH 3/7] [ticket/11543] Add unit tests for obtain_users_online() with empty forum PHPBB3-11543 --- tests/functions/obtain_online_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index efb8e97fc7..8fd7e6a977 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -80,6 +80,22 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case 'hidden_online' => 1, 'guests_online' => 1, )), + array(2, false, array( + 'online_users' => array(), + 'hidden_users' => array(), + 'total_online' => 0, + 'visible_online' => 0, + 'hidden_online' => 0, + 'guests_online' => 0, + )), + array(2, true, array( + 'online_users' => array(), + 'hidden_users' => array(), + 'total_online' => 0, + 'visible_online' => 0, + 'hidden_online' => 0, + 'guests_online' => 0, + )), ); } From 766be31f95ff5b03cba0273cdfd83fb7f0d93a0b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 May 2013 17:23:17 +0200 Subject: [PATCH 4/7] [ticket/11543] Add unit tests for obtain_users_online_string() PHPBB3-11543 --- tests/functions/fixtures/obtain_online.xml | 100 +++++++++++++++++++++ tests/functions/obtain_online_test.php | 86 +++++++++++++++++- 2 files changed, 185 insertions(+), 1 deletion(-) diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml index ea4d6f9238..1c5a4454f2 100644 --- a/tests/functions/fixtures/obtain_online.xml +++ b/tests/functions/fixtures/obtain_online.xml @@ -8,4 +8,104 @@ session_ip session_viewonline + + user_id + username_clean + username + user_allow_viewonline + user_permissions + user_sig + user_occ + user_interests + + 1 + anonymous + anonymous + 1 + + + + + + + 2 + 2 + 2 + 1 + + + + + + + 3 + 3 + 3 + 1 + + + + + + + 4 + 4 + 4 + 1 + + + + + + + 5 + 5 + 5 + 1 + + + + + + + 6 + 6 + 6 + 0 + + + + + + + 7 + 7 + 7 + 0 + + + + + + + 8 + 8 + 8 + 0 + + + + + + + 9 + 9 + 9 + 0 + + + + + +
diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 8fd7e6a977..64f368164c 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -8,6 +8,8 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/auth.php'; class phpbb_functions_obtain_online_test extends phpbb_database_test_case { @@ -18,6 +20,8 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case protected function setUp() { + parent::setUp(); + global $config, $db; $db = $this->db = $this->new_dbal(); @@ -114,6 +118,63 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $this->assertEquals($expected, obtain_users_online($forum_id)); } + static public function obtain_users_online_string_data() + { + return array( + array(0, false, array( + 'online_userlist' => 'REGISTERED_USERS 2, 3', + 'l_online_users' => 'ONLINE_USERS_TOTAL 4REG_USERS_TOTAL_AND 2HIDDEN_USERS_TOTAL 2', + )), + array(0, true, array( + 'online_userlist' => 'REGISTERED_USERS 2, 3', + 'l_online_users' => 'ONLINE_USERS_TOTAL 6REG_USERS_TOTAL 2HIDDEN_USERS_TOTAL_AND 2GUEST_USERS_TOTAL 2', + )), + array(1, false, array( + 'online_userlist' => 'BROWSING_FORUM 3', + 'l_online_users' => 'ONLINE_USERS_TOTAL 2REG_USER_TOTAL_AND 1HIDDEN_USER_TOTAL 1', + )), + array(1, true, array( + 'online_userlist' => 'BROWSING_FORUM_GUEST 3 1', + 'l_online_users' => 'ONLINE_USERS_TOTAL 3REG_USER_TOTAL 1HIDDEN_USER_TOTAL_AND 1GUEST_USER_TOTAL 1', + )), + array(2, false, array( + 'online_userlist' => 'BROWSING_FORUM NO_ONLINE_USERS', + 'l_online_users' => 'ONLINE_USERS_ZERO_TOTAL 0REG_USERS_ZERO_TOTAL_AND 0HIDDEN_USERS_ZERO_TOTAL 0', + )), + array(2, true, array( + 'online_userlist' => 'BROWSING_FORUM_GUESTS NO_ONLINE_USERS 0', + 'l_online_users' => 'ONLINE_USERS_ZERO_TOTAL 0REG_USERS_ZERO_TOTAL 0HIDDEN_USERS_ZERO_TOTAL_AND 0GUEST_USERS_ZERO_TOTAL 0', + )), + ); + } + + /** + * @dataProvider obtain_users_online_string_data + */ + public function test_obtain_users_online_string($forum_id, $display_guests, $expected) + { + $this->db->sql_query('DELETE FROM phpbb_sessions'); + + global $config, $user, $auth; + $config['load_online_guests'] = $display_guests; + $user->lang = $this->load_language(); + $auth = $this->getMock('auth'); + $acl_get_map = array( + array('u_viewonline', true), + ); + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), + $this->anything()) + ->will($this->returnValueMap($acl_get_map)); + + $this->create_guest_sessions(); + $this->create_user_sessions(); + + $online_users = obtain_users_online($forum_id); + $this->assertEquals($expected, obtain_users_online_string($online_users, $forum_id)); + } + protected function create_guest_sessions() { $this->add_session(1, '0001', 0, true, 0); @@ -144,7 +205,30 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case 'session_time' => time() - $time_delta * 60, 'session_viewonline' => $view_online, ); - $this->db->sql_query('INSERT INTO phpbb_sessions ' . $this->db->sql_build_array('INSERT', $sql_ary)); } + + protected function load_language() + { + $lang = array( + 'NO_ONLINE_USERS' => 'NO_ONLINE_USERS', + 'REGISTERED_USERS' => 'REGISTERED_USERS', + 'BROWSING_FORUM' => 'BROWSING_FORUM %s', + 'BROWSING_FORUM_GUEST' => 'BROWSING_FORUM_GUEST %s %d', + 'BROWSING_FORUM_GUESTS' => 'BROWSING_FORUM_GUESTS %s %d', + ); + $vars_online = array('ONLINE', 'REG', 'HIDDEN', 'GUEST'); + foreach ($vars_online as $online) + { + $lang = array_merge($lang, array( + $online . '_USERS_ZERO_TOTAL' => $online . '_USERS_ZERO_TOTAL %d', + $online . '_USER_TOTAL' => $online . '_USER_TOTAL %d', + $online . '_USERS_TOTAL' => $online . '_USERS_TOTAL %d', + $online . '_USERS_ZERO_TOTAL_AND' => $online . '_USERS_ZERO_TOTAL_AND %d', + $online . '_USER_TOTAL_AND' => $online . '_USER_TOTAL_AND %d', + $online . '_USERS_TOTAL_AND' => $online . '_USERS_TOTAL_AND %d', + )); + } + return $lang; + } } From ba665412ea4342da24b70408335e82a8c455f258 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 May 2013 17:56:48 +0200 Subject: [PATCH 5/7] [ticket/11543] Use correct IP addresses and inject time for correct values PHPBB3-11543 --- tests/functions/obtain_online_test.php | 47 ++++++++++++++------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 64f368164c..941c20de92 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -45,7 +45,8 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case { $this->db->sql_query('DELETE FROM phpbb_sessions'); - $this->create_guest_sessions(); + $time = time(); + $this->create_guest_sessions($time); $this->assertEquals($expected, obtain_guest_count($forum_id)); } @@ -113,8 +114,9 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case global $config; $config['load_online_guests'] = $display_guests; - $this->create_guest_sessions(); - $this->create_user_sessions(); + $time = time(); + $this->create_guest_sessions($time); + $this->create_user_sessions($time); $this->assertEquals($expected, obtain_users_online($forum_id)); } @@ -168,41 +170,42 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $this->anything()) ->will($this->returnValueMap($acl_get_map)); - $this->create_guest_sessions(); - $this->create_user_sessions(); + $time = time(); + $this->create_guest_sessions($time); + $this->create_user_sessions($time); $online_users = obtain_users_online($forum_id); $this->assertEquals($expected, obtain_users_online_string($online_users, $forum_id)); } - protected function create_guest_sessions() + protected function create_guest_sessions($time) { - $this->add_session(1, '0001', 0, true, 0); - $this->add_session(1, '0002', 1, true, 0); - $this->add_session(1, '0003', 0, true, 10); - $this->add_session(1, '0004', 1, true, 10); + $this->add_session(1, '0001', '192.168.0.1', 0, true, $time); + $this->add_session(1, '0002', '192.168.0.2', 1, true, $time); + $this->add_session(1, '0003', '192.168.0.3', 0, true, $time, 10); + $this->add_session(1, '0004', '192.168.0.4', 1, true, $time, 10); } - protected function create_user_sessions() + protected function create_user_sessions($time) { - $this->add_session(2, '0005', 0, true, 0); - $this->add_session(3, '0006', 1, true, 0); - $this->add_session(4, '0007', 0, true, 10); - $this->add_session(5, '0008', 1, true, 10); - $this->add_session(6, '0005', 0, false, 0); - $this->add_session(7, '0006', 1, false, 0); - $this->add_session(8, '0007', 0, false, 10); - $this->add_session(9, '0008', 1, false, 10); + $this->add_session(2, '0005', '192.168.0.5', 0, true, $time); + $this->add_session(3, '0006', '192.168.0.6', 1, true, $time); + $this->add_session(4, '0007', '192.168.0.7', 0, true, $time, 10); + $this->add_session(5, '0008', '192.168.0.8', 1, true, $time, 10); + $this->add_session(6, '0005', '192.168.0.9', 0, false, $time); + $this->add_session(7, '0006', '192.168.0.10', 1, false, $time); + $this->add_session(8, '0007', '192.168.0.11', 0, false, $time, 10); + $this->add_session(9, '0008', '192.168.0.12', 1, false, $time, 10); } - protected function add_session($user_id, $user_ip, $forum_id, $view_online, $time_delta) + protected function add_session($user_id, $session_id, $user_ip, $forum_id, $view_online, $time, $time_delta = 0) { $sql_ary = array( - 'session_id' => $user_id . '_' . $forum_id . '_session00000000000000000' . $user_ip, + 'session_id' => $user_id . '_' . $forum_id . '_session00000000000000000' . $session_id, 'session_user_id' => $user_id, 'session_ip' => $user_ip, 'session_forum_id' => $forum_id, - 'session_time' => time() - $time_delta * 60, + 'session_time' => $time - $time_delta * 60, 'session_viewonline' => $view_online, ); $this->db->sql_query('INSERT INTO phpbb_sessions ' . $this->db->sql_build_array('INSERT', $sql_ary)); From d406dd99d84a5c4f2b879859f11b2d10b01d54de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 23:29:50 +0200 Subject: [PATCH 6/7] [ticket/develop/11543] Use plurals in develop PHPBB3-11543 --- tests/functions/obtain_online_test.php | 39 +++++++++----------------- tests/mock/lang.php | 5 ++++ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 941c20de92..30e743cbab 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -9,7 +9,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/auth.php'; class phpbb_functions_obtain_online_test extends phpbb_database_test_case { @@ -125,27 +124,27 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case return array( array(0, false, array( 'online_userlist' => 'REGISTERED_USERS 2, 3', - 'l_online_users' => 'ONLINE_USERS_TOTAL 4REG_USERS_TOTAL_AND 2HIDDEN_USERS_TOTAL 2', + 'l_online_users' => 'ONLINE_USERS_TOTAL 4 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 2', )), array(0, true, array( 'online_userlist' => 'REGISTERED_USERS 2, 3', - 'l_online_users' => 'ONLINE_USERS_TOTAL 6REG_USERS_TOTAL 2HIDDEN_USERS_TOTAL_AND 2GUEST_USERS_TOTAL 2', + 'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 6 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 2 GUEST_USERS_TOTAL 2', )), array(1, false, array( 'online_userlist' => 'BROWSING_FORUM 3', - 'l_online_users' => 'ONLINE_USERS_TOTAL 2REG_USER_TOTAL_AND 1HIDDEN_USER_TOTAL 1', + 'l_online_users' => 'ONLINE_USERS_TOTAL 2 REG_USERS_TOTAL 1 HIDDEN_USERS_TOTAL 1', )), array(1, true, array( - 'online_userlist' => 'BROWSING_FORUM_GUEST 3 1', - 'l_online_users' => 'ONLINE_USERS_TOTAL 3REG_USER_TOTAL 1HIDDEN_USER_TOTAL_AND 1GUEST_USER_TOTAL 1', + 'online_userlist' => 'BROWSING_FORUM_GUESTS 1 3', + 'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 3 REG_USERS_TOTAL 1 HIDDEN_USERS_TOTAL 1 GUEST_USERS_TOTAL 1', )), array(2, false, array( 'online_userlist' => 'BROWSING_FORUM NO_ONLINE_USERS', - 'l_online_users' => 'ONLINE_USERS_ZERO_TOTAL 0REG_USERS_ZERO_TOTAL_AND 0HIDDEN_USERS_ZERO_TOTAL 0', + 'l_online_users' => 'ONLINE_USERS_TOTAL 0 REG_USERS_TOTAL 0 HIDDEN_USERS_TOTAL 0', )), array(2, true, array( - 'online_userlist' => 'BROWSING_FORUM_GUESTS NO_ONLINE_USERS 0', - 'l_online_users' => 'ONLINE_USERS_ZERO_TOTAL 0REG_USERS_ZERO_TOTAL 0HIDDEN_USERS_ZERO_TOTAL_AND 0GUEST_USERS_ZERO_TOTAL 0', + 'online_userlist' => 'BROWSING_FORUM_GUESTS 0 NO_ONLINE_USERS', + 'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 0 REG_USERS_TOTAL 0 HIDDEN_USERS_TOTAL 0 GUEST_USERS_TOTAL 0', )), ); } @@ -157,18 +156,21 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case { $this->db->sql_query('DELETE FROM phpbb_sessions'); - global $config, $user, $auth; + global $config, $user, $auth, $phpbb_dispatcher; $config['load_online_guests'] = $display_guests; + $user = new phpbb_mock_lang(); $user->lang = $this->load_language(); - $auth = $this->getMock('auth'); + $auth = $this->getMock('phpbb_auth'); $acl_get_map = array( array('u_viewonline', true), + array('u_viewprofile', true), ); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($acl_get_map)); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $time = time(); $this->create_guest_sessions($time); @@ -213,25 +215,12 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case protected function load_language() { - $lang = array( + return array( 'NO_ONLINE_USERS' => 'NO_ONLINE_USERS', 'REGISTERED_USERS' => 'REGISTERED_USERS', 'BROWSING_FORUM' => 'BROWSING_FORUM %s', 'BROWSING_FORUM_GUEST' => 'BROWSING_FORUM_GUEST %s %d', 'BROWSING_FORUM_GUESTS' => 'BROWSING_FORUM_GUESTS %s %d', ); - $vars_online = array('ONLINE', 'REG', 'HIDDEN', 'GUEST'); - foreach ($vars_online as $online) - { - $lang = array_merge($lang, array( - $online . '_USERS_ZERO_TOTAL' => $online . '_USERS_ZERO_TOTAL %d', - $online . '_USER_TOTAL' => $online . '_USER_TOTAL %d', - $online . '_USERS_TOTAL' => $online . '_USERS_TOTAL %d', - $online . '_USERS_ZERO_TOTAL_AND' => $online . '_USERS_ZERO_TOTAL_AND %d', - $online . '_USER_TOTAL_AND' => $online . '_USER_TOTAL_AND %d', - $online . '_USERS_TOTAL_AND' => $online . '_USERS_TOTAL_AND %d', - )); - } - return $lang; } } diff --git a/tests/mock/lang.php b/tests/mock/lang.php index 781b3d060e..ac814b45db 100644 --- a/tests/mock/lang.php +++ b/tests/mock/lang.php @@ -30,4 +30,9 @@ class phpbb_mock_lang implements ArrayAccess public function offsetUnset($offset) { } + + public function lang() + { + return implode(' ', func_get_args()); + } } From d39ed5afc13285c1d6d14ea0d04be87dd11f7d38 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Jun 2013 14:48:50 +0200 Subject: [PATCH 7/7] [ticket/11543] Add more users so #hidden <> #normal PHPBB3-11543 --- tests/functions/fixtures/obtain_online.xml | 10 ++++++++++ tests/functions/obtain_online_test.php | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml index 1c5a4454f2..05bbe6a05e 100644 --- a/tests/functions/fixtures/obtain_online.xml +++ b/tests/functions/fixtures/obtain_online.xml @@ -107,5 +107,15 @@ + + 10 + 10 + 10 + 0 + + + + + diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 941c20de92..b3beb55a96 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -54,19 +54,19 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case { return array( array(0, false, array( - 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7), - 'hidden_users' => array(6 => 6, 7 => 7), - 'total_online' => 4, + 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7, 10 => 10), + 'hidden_users' => array(6 => 6, 7 => 7, 10 => 10), + 'total_online' => 5, 'visible_online' => 2, - 'hidden_online' => 2, + 'hidden_online' => 3, 'guests_online' => 0, )), array(0, true, array( - 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7), - 'hidden_users' => array(6 => 6, 7 => 7), - 'total_online' => 6, + 'online_users' => array(2 => 2, 3 => 3, 6 => 6, 7 => 7, 10 => 10), + 'hidden_users' => array(6 => 6, 7 => 7, 10 => 10), + 'total_online' => 7, 'visible_online' => 2, - 'hidden_online' => 2, + 'hidden_online' => 3, 'guests_online' => 2, )), array(1, false, array( @@ -125,11 +125,11 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case return array( array(0, false, array( 'online_userlist' => 'REGISTERED_USERS 2, 3', - 'l_online_users' => 'ONLINE_USERS_TOTAL 4REG_USERS_TOTAL_AND 2HIDDEN_USERS_TOTAL 2', + 'l_online_users' => 'ONLINE_USERS_TOTAL 5REG_USERS_TOTAL_AND 2HIDDEN_USERS_TOTAL 3', )), array(0, true, array( 'online_userlist' => 'REGISTERED_USERS 2, 3', - 'l_online_users' => 'ONLINE_USERS_TOTAL 6REG_USERS_TOTAL 2HIDDEN_USERS_TOTAL_AND 2GUEST_USERS_TOTAL 2', + 'l_online_users' => 'ONLINE_USERS_TOTAL 7REG_USERS_TOTAL 2HIDDEN_USERS_TOTAL_AND 3GUEST_USERS_TOTAL 2', )), array(1, false, array( 'online_userlist' => 'BROWSING_FORUM 3', @@ -196,6 +196,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $this->add_session(7, '0006', '192.168.0.10', 1, false, $time); $this->add_session(8, '0007', '192.168.0.11', 0, false, $time, 10); $this->add_session(9, '0008', '192.168.0.12', 1, false, $time, 10); + $this->add_session(10, '009', '192.168.0.13', 0, false, $time); } protected function add_session($user_id, $session_id, $user_ip, $forum_id, $view_online, $time, $time_delta = 0)