From 920cb1a0de10febca3c78ef13286a49838656ab2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Mar 2012 13:38:02 +0100 Subject: [ticket/10714] Add unit tests for view_log function PHPBB3-10714 --- tests/log/function_view_log_test.php | 341 +++++++++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 tests/log/function_view_log_test.php (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php new file mode 100644 index 0000000000..7c44413330 --- /dev/null +++ b/tests/log/function_view_log_test.php @@ -0,0 +1,341 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/full_log.xml'); + } + + public static function test_view_log_function_data() + { + global $phpEx; + + $expected_data_sets = array( + 1 => array( + 'id' => 1, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => 'installed: 3.1.0-dev', + ), + 2 => array( + 'id' => 2, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG KEY NOT EXISTS}
additional_data', + ), + 3 => array( + 'id' => 3, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG CRITICAL}
critical data', + ), + 4 => array( + 'id' => 4, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 34, + + 'viewforum' => '', + 'action' => '{LOG MOD}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 5 => array( + 'id' => 5, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 45, + + 'viewforum' => '', + 'action' => '{LOG MOD}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 6 => array( + 'id' => 6, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 23, + 'topic_id' => 56, + + 'viewforum' => append_sid("phpBB/viewforum.$phpEx", 'f=23'), + 'action' => '{LOG MOD}', + 'viewtopic' => append_sid("phpBB/viewtopic.$phpEx", 'f=23&t=56'), + 'viewlogs' => append_sid("phpBB/mcp.$phpEx", 'i=logs&mode=topic_logs&t=56'), + ), + 7 => array( + 'id' => 7, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 45, + + 'viewforum' => '', + 'action' => '{LOG MOD2}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 8 => array( + 'id' => 8, + + 'reportee_id' => 2, + 'reportee_username' => 'admin', + 'reportee_username_full'=> 'admin', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG USER}
admin', + ), + 9 => array( + 'id' => 9, + + 'reportee_id' => 1, + 'reportee_username' => 'Anonymous', + 'reportee_username_full'=> 'Anonymous', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG USER}
guest', + ), + ); + + $test_cases = array( + array( + 'expected' => array(1, 2), + 'expected_returned' => 0, + false, + 'admin', + ), + array( + 'expected' => array(1), + 'expected_returned' => 0, + false, + 'admin', 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + false, + 'admin', 1, 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + 0, + 'admin', 1, 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + 0, + 'admin', 1, 5, + ), + array( + 'expected' => array(3), + 'expected_returned' => 0, + false, + 'critical', + ), + array( + 'expected' => array(), + 'expected_returned' => null, + false, + 'mode_does_not_exist', + ), + array( + 'expected' => array(4, 5, 7), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 12, + ), + array( + 'expected' => array(5, 7), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 12, 45, + ), + array( + 'expected' => array(6), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 23, + ), + array( + 'expected' => array(8), + 'expected_returned' => 0, + 0, + 'user', 5, 0, 0, 0, 2, + ), + array( + 'expected' => array(8, 9), + 'expected_returned' => 0, + 0, + 'users', + ), + ); + + foreach ($test_cases as $case => $case_data) + { + foreach ($case_data['expected'] as $data_set => $expected) + { + $test_cases[$case]['expected'][$data_set] = $expected_data_sets[$expected]; + } + } + + return $test_cases; + } + + /** + * @dataProvider test_view_log_function_data + */ + public function test_view_log_function($expected, $expected_returned, $log_count, $mode, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') + { + global $cache, $db, $user, $auth; + + $db = $this->new_dbal(); + $cache = new phpbb_mock_cache; + + // Create auth mock + $auth = $this->getMock('auth'); + $acl_get_map = array( + array('f_read', 23, true), + array('m_', 23, true), + ); + $acl_gets_map = array( + array('a_', 'm_', 23, true), + ); + + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), + $this->anything()) + ->will($this->returnValueMap($acl_get_map)); + $auth->expects($this->any()) + ->method('acl_gets') + ->with($this->stringContains('_'), + $this->anything()) + ->will($this->returnValueMap($acl_gets_map)); + + $user = new phpbb_mock_user; + $user->optionset('viewcensors', false); + // Test sprintf() of the data into the action + $user->lang = array( + 'LOG_INSTALL_INSTALLED' => 'installed: %s', + ); + + $log = array(); + $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); + + $this->assertEquals($expected, $log); + } +} -- cgit v1.2.1 From 1e00c697b766d1a8695c8e058334efe1dd3dbb7e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 17:02:56 +0100 Subject: [ticket/10714] Add docblock for the test cases PHPBB3-10714 --- tests/log/function_view_log_test.php | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 7c44413330..78bc2843a8 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -210,77 +210,77 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case ); $test_cases = array( + /** + * Case documentation + array( + // Array of datasets that should be in $log after running the function + 'expected' => array(5, 7), + // Offset that will be returned form the function + 'expected_returned' => 0, + // view_log parameters (see includes/functions_admin.php for docblock) + // $log is ommited! + 'mod', 5, 0, 12, 45, + ), + */ array( 'expected' => array(1, 2), 'expected_returned' => 0, - false, - 'admin', + 'admin', false, ), array( 'expected' => array(1), 'expected_returned' => 0, - false, - 'admin', 1, + 'admin', false, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - false, - 'admin', 1, 1, + 'admin', false, 1, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - 0, - 'admin', 1, 1, + 'admin', 0, 1, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - 0, - 'admin', 1, 5, + 'admin', 0, 1, 5, ), array( 'expected' => array(3), 'expected_returned' => 0, - false, - 'critical', + 'critical', false, ), array( 'expected' => array(), 'expected_returned' => null, - false, - 'mode_does_not_exist', + 'mode_does_not_exist', false, ), array( 'expected' => array(4, 5, 7), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 12, + 'mod', 0, 5, 0, 12, ), array( 'expected' => array(5, 7), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 12, 45, + 'mod', 0, 5, 0, 12, 45, ), array( 'expected' => array(6), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 23, + 'mod', 0, 5, 0, 23, ), array( 'expected' => array(8), 'expected_returned' => 0, - 0, - 'user', 5, 0, 0, 0, 2, + 'user', 0, 5, 0, 0, 0, 2, ), array( 'expected' => array(8, 9), 'expected_returned' => 0, - 0, - 'users', + 'users', 0, ), ); @@ -298,7 +298,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case /** * @dataProvider test_view_log_function_data */ - public function test_view_log_function($expected, $expected_returned, $log_count, $mode, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') + public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { global $cache, $db, $user, $auth; -- cgit v1.2.1 From d828ef93f29eda5fe31a6f8291dd1e5b3cdfd97c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 16:00:01 +0200 Subject: [ticket/10714] Fix unit test because of events and moved files PHPBB3-10714 --- tests/log/function_view_log_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 78bc2843a8..790597e9c8 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -7,13 +7,12 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/auth.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; -require_once dirname(__FILE__) . '/../mock_user.php'; +require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; class phpbb_log_function_view_log_test extends phpbb_database_test_case @@ -300,13 +299,14 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { - global $cache, $db, $user, $auth; + global $cache, $db, $user, $auth, $phpbb_dispatcher; $db = $this->new_dbal(); $cache = new phpbb_mock_cache; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // Create auth mock - $auth = $this->getMock('auth'); + $auth = $this->getMock('phpbb_auth'); $acl_get_map = array( array('f_read', 23, true), array('m_', 23, true), -- cgit v1.2.1 From 0f94ff91383ee0ed533048db96a34164ba94b0a4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 16:05:57 +0100 Subject: [ticket/10714] Add global variables for the unit tests PHPBB3-10714 --- tests/log/function_view_log_test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 790597e9c8..f7e2c51c32 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -24,7 +24,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case public static function test_view_log_function_data() { - global $phpEx; + global $phpEx, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $expected_data_sets = array( 1 => array( @@ -299,11 +300,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { - global $cache, $db, $user, $auth, $phpbb_dispatcher; + global $cache, $db, $user, $auth, $phpbb_log, $phpbb_dispatcher; $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_log = new phpbb_log(LOGS_TABLE); // Create auth mock $auth = $this->getMock('phpbb_auth'); -- cgit v1.2.1 From f4bc9c1673c18ed24a2ba1680f6b9a5de5c491bf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Dec 2012 10:24:49 +0100 Subject: [ticket/10714] Fix dependency injections in unit tests with mocks PHPBB3-10714 --- tests/log/function_view_log_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index f7e2c51c32..bb33668ae4 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -300,12 +300,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { - global $cache, $db, $user, $auth, $phpbb_log, $phpbb_dispatcher; + global $cache, $db, $user, $auth, $phpbb_log, $phpbb_dispatcher, $phpbb_root_path, $phpEx; $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_log = new phpbb_log(LOGS_TABLE); // Create auth mock $auth = $this->getMock('phpbb_auth'); @@ -335,6 +334,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', ); + $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $phpEx, LOG_TABLE); + $log = array(); $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); -- cgit v1.2.1 From 37014abd022be4f7824a590b93a329f74aef442c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Jan 2013 14:18:09 +0100 Subject: [ticket/10714] Fix several comments and variable names PHPBB3-10714 --- tests/log/function_view_log_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index bb33668ae4..7401e1ee4f 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -215,7 +215,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case array( // Array of datasets that should be in $log after running the function 'expected' => array(5, 7), - // Offset that will be returned form the function + // Offset that will be returned from the function 'expected_returned' => 0, // view_log parameters (see includes/functions_admin.php for docblock) // $log is ommited! -- cgit v1.2.1 From 2c4e7eabe248fc785cd2b43f57a42580361c599d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 22 Jan 2013 15:10:35 +0100 Subject: [ticket/10714] Fix missing 8th argument in unit tests PHPBB3-10714 --- tests/log/function_view_log_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 7401e1ee4f..2ecf77aeb8 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -334,7 +334,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', ); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $phpEx, LOG_TABLE); + $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $log = array(); $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); -- cgit v1.2.1 From 1431a027563b717183937751970f52cc0a4c94fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 19 Apr 2013 01:49:35 +0200 Subject: [ticket/11501] Remove test_ prefix from data provider methods PHPBB3-11501 --- tests/log/function_view_log_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 2ecf77aeb8..1ab9488568 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -22,7 +22,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/full_log.xml'); } - public static function test_view_log_function_data() + public static function view_log_function_data() { global $phpEx, $phpbb_dispatcher; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); @@ -296,7 +296,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case } /** - * @dataProvider test_view_log_function_data + * @dataProvider view_log_function_data */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { -- cgit v1.2.1 From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- tests/log/function_view_log_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 1ab9488568..6827aaa1b6 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; -- 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/log/function_view_log_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 6827aaa1b6..017484e8a7 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -306,7 +306,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $acl_get_map = array( array('f_read', 23, true), array('m_', 23, true), @@ -333,7 +333,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', ); - $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); $log = array(); $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); -- cgit v1.2.1 From 2fcfca73696bd7cc24dbadee147ee7a72526b3b7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 1 Apr 2014 23:10:29 +0200 Subject: [ticket/12113] Fix view_log() tests PHPBB3-12113 --- tests/log/function_view_log_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 017484e8a7..9148d23bb4 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -44,7 +44,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'topic_id' => 0, 'viewforum' => '', - 'action' => 'installed: 3.1.0-dev', + 'action' => 'LOG_INSTALL_INSTALLED 3.1.0-dev', ), 2 => array( 'id' => 2, -- cgit v1.2.1 From 68bd70ef376cc3c6a5ac89e5c29f33df9247df9d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 13:09:16 +0200 Subject: [ticket/12388] Add tests for lang() use on log actions without data PHPBB3-12388 --- tests/log/function_view_log_test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 9148d23bb4..2ddf7522f4 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -164,7 +164,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'topic_id' => 45, 'viewforum' => '', - 'action' => '{LOG MOD2}', + 'action' => 'LOG_MOD2', 'viewtopic' => '', 'viewlogs' => '', ), @@ -185,7 +185,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'topic_id' => 0, 'viewforum' => '', - 'action' => '{LOG USER}
admin', + 'action' => 'LOG_USER admin', ), 9 => array( 'id' => 9, @@ -204,7 +204,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'topic_id' => 0, 'viewforum' => '', - 'action' => '{LOG USER}
guest', + 'action' => 'LOG_USER guest', ), ); @@ -331,6 +331,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case // Test sprintf() of the data into the action $user->lang = array( 'LOG_INSTALL_INSTALLED' => 'installed: %s', + 'LOG_USER' => 'User
%s', + 'LOG_MOD2' => 'Mod2', ); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); -- cgit v1.2.1 From bf3425b0f84f9880ee7e92c1658bbc5412eaccaa Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 22 Apr 2014 02:44:34 +0200 Subject: [ticket/12422] Add tests PHPBB3-12422 --- tests/log/function_view_log_test.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 2ddf7522f4..2f64459062 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -206,6 +206,25 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'viewforum' => '', 'action' => 'LOG_USER guest', ), + 10 => array( + 'id' => 10, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => 'LOG_SINGULAR_PLURAL 2', + ), ); $test_cases = array( @@ -277,10 +296,20 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user', 0, 5, 0, 0, 0, 2, ), array( - 'expected' => array(8, 9), + 'expected' => array(8, 9, 10), 'expected_returned' => 0, 'users', 0, ), + array( + 'expected' => array(1), + 'expected_returned' => 0, + 'admin', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'install', + ), + array( + 'expected' => array(10), + 'expected_returned' => 0, + 'user', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'plural', + ), ); foreach ($test_cases as $case => $case_data) @@ -333,6 +362,10 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', 'LOG_USER' => 'User
%s', 'LOG_MOD2' => 'Mod2', + 'LOG_SINGULAR_PLURAL' => array( + 1 => 'singular', + 2 => 'plural (%d)', + ), ); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); -- cgit v1.2.1 From 3d1569d38594cb06a9d8a9baa3f64a37ac8c9b43 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sat, 26 Apr 2014 00:42:24 +0200 Subject: [ticket/12444] Adding regression test PHPBB3-12444 --- tests/log/function_view_log_test.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 2f64459062..542d0adf9d 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -225,6 +225,27 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'viewforum' => '', 'action' => 'LOG_SINGULAR_PLURAL 2', ), + 11 => array( + 'id' => 11, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 15, + 'topic_id' => 3, + + 'viewforum' => '', + 'action' => 'LOG_MOD3 guest ', + 'viewtopic' => '', + 'viewlogs' => '', + ), ); $test_cases = array( @@ -310,6 +331,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'expected_returned' => 0, 'user', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'plural', ), + array( + 'expected' => array(11), + 'expected_returned' => 0, + 'mod', 0, 5, 0, 15, 3, + ), ); foreach ($test_cases as $case => $case_data) @@ -362,6 +388,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', 'LOG_USER' => 'User
%s', 'LOG_MOD2' => 'Mod2', + 'LOG_MOD3' => 'Mod3: %1$s, %2$s', 'LOG_SINGULAR_PLURAL' => array( 1 => 'singular', 2 => 'plural (%d)', -- 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/log/function_view_log_test.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 542d0adf9d..b7e60c7393 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_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 From 665742945f37a11a84ff3dc7190607a048fee485 Mon Sep 17 00:00:00 2001 From: PayBas Date: Wed, 25 Jun 2014 09:33:48 +0200 Subject: [ticket/12662] Update tests that utilize get_username_string PHPBB3-12662 --- tests/log/function_view_log_test.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/log/function_view_log_test.php') diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index b7e60c7393..02e0b3912f 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -40,7 +40,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -59,7 +59,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -78,7 +78,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -97,7 +97,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -118,7 +118,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -139,7 +139,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -160,7 +160,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -177,11 +177,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'reportee_id' => 2, 'reportee_username' => 'admin', - 'reportee_username_full'=> 'admin', + 'reportee_username_full'=> 'admin', 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -196,11 +196,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'reportee_id' => 1, 'reportee_username' => 'Anonymous', - 'reportee_username_full'=> 'Anonymous', + 'reportee_username_full'=> 'Anonymous', 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -219,7 +219,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, @@ -238,7 +238,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'user_id' => 1, 'username' => 'Anonymous', - 'username_full' => 'Anonymous', + 'username_full' => 'Anonymous', 'ip' => '127.0.0.1', 'time' => 1, -- cgit v1.2.1