From 9c0a03f1d56d069a5ca5092de8e0f3e4e6ee9c1d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 29 Nov 2012 12:05:52 -0500 Subject: [ticket/11095] Python quoteattr port. PHPBB3-11095 --- tests/functions/quoteattr_test.php | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/functions/quoteattr_test.php (limited to 'tests/functions') diff --git a/tests/functions/quoteattr_test.php b/tests/functions/quoteattr_test.php new file mode 100644 index 0000000000..9d2a7d470e --- /dev/null +++ b/tests/functions/quoteattr_test.php @@ -0,0 +1,44 @@ +', null, '"<a>"'), + array('&', null, '"&amp;"'), + array('"hello"', null, "'\"hello\"'"), + array("'hello'", null, "\"'hello'\""), + array("\"'", null, "\""'\""), + array("a\nb", null, '"a b"'), + array("a\r\nb", null, '"a b"'), + array("a\tb", null, '"a b"'), + array('a b', null, '"a b"'), + array('"a 'z'), '"zoo"'), + array('', array('a' => '&'), '"<&>"'), + ); + } + + /** + * @dataProvider quoteattr_test_data + */ + public function test_quoteattr($input, $entities, $expected) + { + $output = phpbb_quoteattr($input, $entities); + + $this->assertEquals($expected, $output); + } +} -- cgit v1.2.1 From 3e907265d5782c535d43e503c32390cfde8dc4a8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 29 Nov 2012 14:41:48 -0500 Subject: [ticket/11095] Docs and tests for phpbb_build_hidden_fields_for_query_params. PHPBB3-11095 --- .../build_hidden_fields_for_query_params_test.php | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/functions/build_hidden_fields_for_query_params_test.php (limited to 'tests/functions') diff --git a/tests/functions/build_hidden_fields_for_query_params_test.php b/tests/functions/build_hidden_fields_for_query_params_test.php new file mode 100644 index 0000000000..ef2f5744d3 --- /dev/null +++ b/tests/functions/build_hidden_fields_for_query_params_test.php @@ -0,0 +1,71 @@ + 'bar'), + array(), + array(), + "", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array(), + array(), + "", + ), + array( + array('a' => 'quote"', 'b' => ''), + array(), + array(), + "", + ), + array( + array('a' => "quotes'\""), + array(), + array(), + "", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array('a' => 'c'), + array(), + "", + ), + // strict equality check + array( + array('foo' => 'bar', 'a' => '0'), + array('a' => ''), + array(), + "", + ), + ); + } + + /** + * @dataProvider build_hidden_fields_for_query_params_test_data + */ + public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected) + { + $request = new phpbb_mock_request($get, $post); + $result = phpbb_build_hidden_fields_for_query_params($request, $exclude); + + $this->assertEquals($expected, $result); + } +} -- cgit v1.2.1 From 8e6a69bf0c936d658deeb3714bc2d38b4b8750c8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 18:50:22 -0600 Subject: [ticket/8323] Unit test for phpbb_get_banned_user_ids PHPBB3-8323 --- tests/functions/fixtures/banned_users.xml | 33 +++++++++++++++++++++++++++ tests/functions/phpbb_get_banned_user_ids.php | 33 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/functions/fixtures/banned_users.xml create mode 100644 tests/functions/phpbb_get_banned_user_ids.php (limited to 'tests/functions') diff --git a/tests/functions/fixtures/banned_users.xml b/tests/functions/fixtures/banned_users.xml new file mode 100644 index 0000000000..42b73dd270 --- /dev/null +++ b/tests/functions/fixtures/banned_users.xml @@ -0,0 +1,33 @@ + + + + ban_userid + ban_exclude + ban_end + + 1 + 1 + 0 + + + 2 + 0 + 0 + + + 3 + 0 + 0 + + + 4 + 0 + 2 + + + 5 + 0 + 999999999999999999999 + +
+
diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php new file mode 100644 index 0000000000..226012f68f --- /dev/null +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -0,0 +1,33 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/banned_users.xml'); + } + + public function test_phpbb_get_banned_user_ids() + { + global $db; + + $db = $this->new_dbal(); + + $user_ids = array(1, 2, 4, 5); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, true), array(2 => 2, 5 => 5)); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, false), array(2 => 2)); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, 2), array(2 => 2, 5 => 5)); + } +} -- cgit v1.2.1 From b3dae8fd61a10d82b5bb8e1626214789d3ac7b5c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 20:26:35 -0600 Subject: [ticket/8323] dataProvider for the test; better test data PHPBB3-8323 --- tests/functions/fixtures/banned_users.xml | 5 +++++ tests/functions/phpbb_get_banned_user_ids.php | 25 ++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/fixtures/banned_users.xml b/tests/functions/fixtures/banned_users.xml index 42b73dd270..cec3f4e51f 100644 --- a/tests/functions/fixtures/banned_users.xml +++ b/tests/functions/fixtures/banned_users.xml @@ -29,5 +29,10 @@ 0 999999999999999999999 + + 6 + 0 + 3 + diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 226012f68f..9f56480235 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -16,18 +16,29 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/banned_users.xml'); } - public function test_phpbb_get_banned_user_ids() + public function phpbb_get_banned_user_ids_data() + { + return array( + array(array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5)), + array(array(array(1, 2, 4, 5, 6), false), array(2 => 2)), + array(array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6)), + ); + } + + public function setUp() { global $db; $db = $this->new_dbal(); - $user_ids = array(1, 2, 4, 5); - - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, true), array(2 => 2, 5 => 5)); - - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, false), array(2 => 2)); + return parent::setUp(); + } - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, 2), array(2 => 2, 5 => 5)); + /** + * @dataProvider phpbb_get_banned_user_ids_data + */ + public function test_phpbb_get_banned_user_ids($input, $expected) + { + $this->assertEquals($expected, call_user_func_array('phpbb_get_banned_user_ids', $input)); } } -- cgit v1.2.1 From 12aa6b4b2cfda48f94c44865209f576654632b41 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 11 Dec 2012 11:24:18 -0600 Subject: [ticket/8323] More readability in test case PHPBB3-8323 --- tests/functions/phpbb_get_banned_user_ids.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 9f56480235..76c0204970 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -19,9 +19,20 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case public function phpbb_get_banned_user_ids_data() { return array( - array(array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5)), - array(array(array(1, 2, 4, 5, 6), false), array(2 => 2)), - array(array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6)), + // Input to phpbb_get_banned_user_ids (user_id list, ban_end) + // Expected output + array( + array(array(1, 2, 4, 5, 6), true), + array(2 => 2, 5 => 5), + ), + array( + array(array(1, 2, 4, 5, 6), false), + array(2 => 2), + ), + array( + array(array(1, 2, 4, 5, 6), 2), + array(2 => 2, 5 => 5, 6 => 6), + ), ); } -- cgit v1.2.1 From 9e3fd3bf8e8ff08b159d9151aef6f9bb6b9244ee Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 13 Dec 2012 19:07:49 -0500 Subject: [ticket/11015] Fix 3.0 to 3.1 dbms conversion for mysqli. PHPBB3-11015 --- tests/functions/convert_30_dbms_to_31_test.php | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/functions/convert_30_dbms_to_31_test.php (limited to 'tests/functions') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php new file mode 100644 index 0000000000..d08bf87f15 --- /dev/null +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -0,0 +1,40 @@ +assertEquals($expected, $output); + } +} -- cgit v1.2.1 From d68778e7ebd801d396a8ec8694499f2ebdbb809f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 20:05:00 -0600 Subject: [ticket/8323] Comments on phpbb_get_banned_user_ids input for test PHPBB3-8323 --- tests/functions/phpbb_get_banned_user_ids.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/functions') diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 76c0204970..96de5c5767 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -22,14 +22,17 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case // Input to phpbb_get_banned_user_ids (user_id list, ban_end) // Expected output array( + // True to get users currently banned array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5), ), array( + // False to only get permanently banned users array(array(1, 2, 4, 5, 6), false), array(2 => 2), ), array( + // Unix timestamp to get users banned until that time array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6), ), -- cgit v1.2.1 From 869e00a23b0400b9ad81c1130227cc4c29d6a38d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Apr 2013 17:45:49 +0200 Subject: [ticket/11362] Move phpbb_clean_path into a simple filesystem service PHPBB3-11362 --- tests/functions/clean_path_test.php | 44 ------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 tests/functions/clean_path_test.php (limited to 'tests/functions') diff --git a/tests/functions/clean_path_test.php b/tests/functions/clean_path_test.php deleted file mode 100644 index bcbe9838d9..0000000000 --- a/tests/functions/clean_path_test.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals($expected, $output); - } -} -- cgit v1.2.1 From fd3b257468042fe546916370c4610dc8238c2483 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 15 May 2013 13:52:02 +0200 Subject: [ticket/11540] Add phpbb_ prefix in is_absolute_test from olympus. PHPBB3-11540 --- tests/functions/is_absolute_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/is_absolute_test.php b/tests/functions/is_absolute_test.php index 26425d2a36..64a7a81b4a 100644 --- a/tests/functions/is_absolute_test.php +++ b/tests/functions/is_absolute_test.php @@ -29,6 +29,6 @@ class phpbb_functions_is_absolute_test extends phpbb_test_case */ public function test_is_absolute($path, $expected) { - $this->assertEquals($expected, is_absolute($path)); + $this->assertEquals($expected, phpbb_is_absolute($path)); } } -- cgit v1.2.1 From c338dfcbf2cdd1dc0dce087270b0901cd099c954 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 27 May 2013 15:45:01 +0200 Subject: [ticket/11573] Honor MySQL STRICT_TRANS_TABLES in test_style_select. PHPBB3-11573 --- tests/functions/fixtures/style_select.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/functions') diff --git a/tests/functions/fixtures/style_select.xml b/tests/functions/fixtures/style_select.xml index 12d6392ab5..ca95f94461 100644 --- a/tests/functions/fixtures/style_select.xml +++ b/tests/functions/fixtures/style_select.xml @@ -4,20 +4,24 @@ style_id style_name style_active + style_parent_tree 1 prosilver 1 + 2 subsilver2 1 + 3 zoo 0 + -- cgit v1.2.1 From d406dd99d84a5c4f2b879859f11b2d10b01d54de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 23:29:50 +0200 Subject: [ticket/develop/11543] Use plurals in develop PHPBB3-11543 --- tests/functions/obtain_online_test.php | 39 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'tests/functions') 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; } } -- 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/obtain_online_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index fe372431a9..624e05f77f 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -160,7 +160,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $config['load_online_guests'] = $display_guests; $user = new phpbb_mock_lang(); $user->lang = $this->load_language(); - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $acl_get_map = array( array('u_viewonline', true), array('u_viewprofile', true), -- cgit v1.2.1 From 239381b946e20e98459dfa5f36962df37cd76d82 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 15:19:35 +0200 Subject: [ticket/11700] Fix expected class name output from dbms convert PHPBB3-11700 --- tests/functions/convert_30_dbms_to_31_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index d08bf87f15..95fa226f42 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -31,7 +31,7 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case */ public function test_convert_30_dbms_to_31($input) { - $expected = "phpbb_db_driver_$input"; + $expected = "\\phpbb\\db\\driver\\$input"; $output = phpbb_convert_30_dbms_to_31($input); -- cgit v1.2.1 From bdaf68c113162a98a2e471183a39297e1a965ad3 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 17:45:28 +0200 Subject: [ticket/11700] Don't prefix dbms classnames with \ PHPBB3-11700 --- tests/functions/convert_30_dbms_to_31_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index 95fa226f42..4d210d7b29 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -31,7 +31,7 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case */ public function test_convert_30_dbms_to_31($input) { - $expected = "\\phpbb\\db\\driver\\$input"; + $expected = "phpbb\\db\\driver\\$input"; $output = phpbb_convert_30_dbms_to_31($input); -- cgit v1.2.1 From 417fddf710374a65321974173aa6e3f89cff50b1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:44:33 +0100 Subject: [ticket/12056] Fix "undefined function phpbb_pcre_utf8_support()". PHPBB3-12056 --- tests/functions/validate_password_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functions') diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php index 4639f6cc89..82c5fa03c1 100644 --- a/tests/functions/validate_password_test.php +++ b/tests/functions/validate_password_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; -- cgit v1.2.1 From bbada27ee9e797c7f6ce997152bc1efb8c8f125d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 21:45:59 +0100 Subject: [ticket/12115] Also port user interests to profile fields PHPBB3-12115 --- tests/functions/fixtures/obtain_online.xml | 22 ---------------------- tests/functions/fixtures/validate_email.xml | 4 ---- tests/functions/fixtures/validate_username.xml | 6 ------ 3 files changed, 32 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml index 05bbe6a05e..14621a3287 100644 --- a/tests/functions/fixtures/obtain_online.xml +++ b/tests/functions/fixtures/obtain_online.xml @@ -15,8 +15,6 @@ user_allow_viewonline user_permissions user_sig - user_occ - user_interests 1 anonymous @@ -24,8 +22,6 @@ 1 - - 2 @@ -34,8 +30,6 @@ 1 - - 3 @@ -44,8 +38,6 @@ 1 - - 4 @@ -54,8 +46,6 @@ 1 - - 5 @@ -64,8 +54,6 @@ 1 - - 6 @@ -74,8 +62,6 @@ 0 - - 7 @@ -84,8 +70,6 @@ 0 - - 8 @@ -94,8 +78,6 @@ 0 - - 9 @@ -104,8 +86,6 @@ 0 - - 10 @@ -114,8 +94,6 @@ 0 - - diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml index de7fce8a08..eb4fd90217 100644 --- a/tests/functions/fixtures/validate_email.xml +++ b/tests/functions/fixtures/validate_email.xml @@ -6,8 +6,6 @@ username_clean user_permissions user_sig - user_occ - user_interests user_email_hash 1 @@ -15,8 +13,6 @@ admin - - 143317126117 diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml index fbe398469c..1b85a2f06d 100644 --- a/tests/functions/fixtures/validate_username.xml +++ b/tests/functions/fixtures/validate_username.xml @@ -14,16 +14,12 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 admin admin - - 2 @@ -31,8 +27,6 @@ moderator - - -- cgit v1.2.1 From 2a822931c6d95fe9e6066752ec59ab614189837e Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 19 Mar 2014 03:05:36 -0700 Subject: [ticket/11959] Add unit tests. PHPBB3-11959 --- tests/functions/generate_string_list.php | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/functions/generate_string_list.php (limited to 'tests/functions') diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php new file mode 100644 index 0000000000..60269b5656 --- /dev/null +++ b/tests/functions/generate_string_list.php @@ -0,0 +1,60 @@ +user = new \phpbb\user(); + $this->user->data = array('user_lang' => 'en'); + $this->user->add_lang('common'); + } + + public function generate_string_list_data() + { + return array( + array( + array(), + '', + ), + array( + array('A'), + 'A', + ), + array( + array(2 => 'A', 3 => 'B'), + 'A and B', + ), + array( + array('A' => 'A', 'B' => 'B', 'C' => 'C'), + 'A, B, and C', + ), + array( + array('A', 'B', 'C', 'D'), + 'A, B, C, and D', + ) + ); + } + + /** + * @dataProvider generate_string_list_data + */ + public function test_generate_string_list($items, $expected_result) + { + $result = phpbb_generate_string_list($items, $this->user); + $this->assertEquals($expected_result, $result); + } +} -- cgit v1.2.1 From b893dae105f72b7c34abe855e24f0dec35206208 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 29 Mar 2014 09:29:47 -0700 Subject: [ticket/11959] Move phpbb_generate_string_list() to functions_content.php. PHPBB3-11959 --- tests/functions/generate_string_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index 60269b5656..cfc150c1f4 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.php @@ -7,7 +7,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_display.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_generate_string_list_test extends phpbb_test_case -- cgit v1.2.1 From 0a586258a21e36e45f39fa170d7365f8d879769b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 3 Apr 2014 15:42:36 +0200 Subject: [ticket/12349] Update license header in several new files PHPBB3-12349 --- tests/functions/parse_cfg_file_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/parse_cfg_file_test.php b/tests/functions/parse_cfg_file_test.php index 69000ddf72..920fc2eaa7 100644 --- a/tests/functions/parse_cfg_file_test.php +++ b/tests/functions/parse_cfg_file_test.php @@ -21,7 +21,7 @@ class phpbb_functions_parse_cfg_file extends phpbb_test_case '#', '# @package phpBB3', '# @copyright (c) 2005 phpBB Group', - '# @license http://opensource.org/licenses/gpl-license.php GNU Public License', + '# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2', '#', '#', '# At the left is the name, please do not change this', -- cgit v1.2.1 From 47f8a6375f12d9ca18b88432a8d2e51d168909fe Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 27 Feb 2014 23:33:39 -0800 Subject: [ticket/11508] Add tests. PHPBB3-11508 --- tests/functions/build_url_test.php | 77 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/functions/build_url_test.php (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php new file mode 100644 index 0000000000..8d0aa76317 --- /dev/null +++ b/tests/functions/build_url_test.php @@ -0,0 +1,77 @@ +path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $phpbb_root_path, + 'php' + ); + $phpbb_container->set('path_helper', $path_helper); + } + public function build_url_test_data() + { + return array( + array( + 'index.php', + false, + 'phpBB/index.php?', + ), + array( + 'index.php', + 't', + 'phpBB/index.php?', + ), + array( + 'viewtopic.php?f=2&style=1&t=6', + 'f', + 'phpBB/viewtopic.php?style=1&t=6', + ), + array( + 'viewtopic.php?f=2&style=1&t=6', + array('f', 'style', 't'), + 'phpBB/viewtopic.php', + ), + array( + 'http://test.phpbb.com/viewtopic.php?f=2&style=1&t=6', + array('f', 'style', 't'), + 'http://test.phpbb.com/viewtopic.php', + ), + ); + } + + /** + * @dataProvider build_url_test_data + */ + public function test_build_url($page, $strip_vars, $expected) + { + global $user, $phpbb_root_path; + + $user->page['page'] = $page; + $output = build_url($strip_vars); + + $this->assertEquals($expected, $output); + } +} -- cgit v1.2.1 From 141d386025b8a47a787b95f82058cc3c766a4007 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Fri, 28 Feb 2014 00:02:40 -0800 Subject: [ticket/11508] Fix build_url test. PHPBB3-11508 --- tests/functions/build_url_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 8d0aa76317..7e1c620664 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -21,7 +21,7 @@ class phpbb_build_url_test extends phpbb_test_case $user = new phpbb_mock_user(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $this->path_helper = new \phpbb\path_helper( + $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), @@ -52,12 +52,12 @@ class phpbb_build_url_test extends phpbb_test_case array( 'viewtopic.php?f=2&style=1&t=6', array('f', 'style', 't'), - 'phpBB/viewtopic.php', + 'phpBB/viewtopic.php?', ), array( 'http://test.phpbb.com/viewtopic.php?f=2&style=1&t=6', array('f', 'style', 't'), - 'http://test.phpbb.com/viewtopic.php', + 'http://test.phpbb.com/viewtopic.php?', ), ); } -- cgit v1.2.1 From e9b00071dd1e7ae40a04e26d3f337d70bafbcf93 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 22 Apr 2014 16:03:13 -0700 Subject: [ticket/11508] Fix build_url test. PHPBB3-11508 --- tests/functions/build_url_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 7e1c620664..795427ffe8 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -13,7 +13,7 @@ class phpbb_build_url_test extends phpbb_test_case { protected function setUp() { - global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path; + global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper; parent::setUp(); @@ -21,7 +21,7 @@ class phpbb_build_url_test extends phpbb_test_case $user = new phpbb_mock_user(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $path_helper = new \phpbb\path_helper( + $phpbb_path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), -- cgit v1.2.1 From 6ba61785f8da8df917866055e0119bc4fceeae0d Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sat, 26 Apr 2014 15:46:50 +0200 Subject: [ticket/12097] Bug fix and adding unit test PHPBB3-12097 --- tests/functions/validate_with_method_test.php | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/functions/validate_with_method_test.php (limited to 'tests/functions') diff --git a/tests/functions/validate_with_method_test.php b/tests/functions/validate_with_method_test.php new file mode 100644 index 0000000000..86d7b9571c --- /dev/null +++ b/tests/functions/validate_with_method_test.php @@ -0,0 +1,39 @@ +helper = new phpbb_functions_validate_data_helper($this); + } + + public function test_validate_date() + { + $this->helper->assert_valid_data(array( + 'method_call' => array( + array(), + true, + array(array(array($this, 'with_method'), false)), + ), + )); + } + + public function validate_with_method($bool, $optional = false) + { + return ! $bool; + } +} -- cgit v1.2.1 From eddb4203757366eef2afc81d53d948d3aaeed0c7 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 6 May 2014 14:54:51 -0700 Subject: [ticket/12510] Convert & to & in build_url() when no params are stripped. PHPBB3-12510 --- tests/functions/build_url_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 795427ffe8..ad36f29b8c 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -44,6 +44,11 @@ class phpbb_build_url_test extends phpbb_test_case 't', 'phpBB/index.php?', ), + array( + 'viewtopic.php?t=5&f=4', + false, + 'phpBB/viewtopic.php?t=5&f=4', + ), array( 'viewtopic.php?f=2&style=1&t=6', 'f', -- 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/build_hidden_fields_for_query_params_test.php | 10 +++++++--- tests/functions/build_url_test.php | 10 +++++++--- tests/functions/convert_30_dbms_to_31_test.php | 10 +++++++--- tests/functions/generate_string_list.php | 10 +++++++--- tests/functions/get_formatted_filesize_test.php | 10 +++++++--- tests/functions/get_remote_file_test.php | 10 +++++++--- tests/functions/is_absolute_test.php | 10 +++++++--- tests/functions/language_select_test.php | 10 +++++++--- tests/functions/obtain_online_test.php | 10 +++++++--- tests/functions/parse_cfg_file_test.php | 10 +++++++--- tests/functions/phpbb_get_banned_user_ids.php | 10 +++++++--- tests/functions/quoteattr_test.php | 10 +++++++--- tests/functions/style_select_test.php | 10 +++++++--- tests/functions/validate_data_helper.php | 10 +++++++--- tests/functions/validate_date_test.php | 10 +++++++--- tests/functions/validate_email_test.php | 10 +++++++--- tests/functions/validate_hex_colour_test.php | 10 +++++++--- tests/functions/validate_jabber_test.php | 10 +++++++--- tests/functions/validate_lang_iso_test.php | 10 +++++++--- tests/functions/validate_match_test.php | 10 +++++++--- tests/functions/validate_num_test.php | 10 +++++++--- tests/functions/validate_password_test.php | 10 +++++++--- tests/functions/validate_string_test.php | 10 +++++++--- tests/functions/validate_username_test.php | 10 +++++++--- tests/functions/validate_with_method_test.php | 10 +++++++--- 25 files changed, 175 insertions(+), 75 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/build_hidden_fields_for_query_params_test.php b/tests/functions/build_hidden_fields_for_query_params_test.php index ef2f5744d3..14cb4b9a94 100644 --- a/tests/functions/build_hidden_fields_for_query_params_test.php +++ b/tests/functions/build_hidden_fields_for_query_params_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. * */ diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index ad36f29b8c..7a70bddc71 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_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. * */ diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index 4d210d7b29..9647eb341c 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_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. * */ diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index cfc150c1f4..32a04c1501 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.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. * */ diff --git a/tests/functions/get_formatted_filesize_test.php b/tests/functions/get_formatted_filesize_test.php index 96ea2be132..635753d737 100644 --- a/tests/functions/get_formatted_filesize_test.php +++ b/tests/functions/get_formatted_filesize_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. * */ diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index 4032ca5b58..d412dce164 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_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. * */ diff --git a/tests/functions/is_absolute_test.php b/tests/functions/is_absolute_test.php index 6d26793d82..afa4b9b59f 100644 --- a/tests/functions/is_absolute_test.php +++ b/tests/functions/is_absolute_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. * */ diff --git a/tests/functions/language_select_test.php b/tests/functions/language_select_test.php index 3341e2a256..6762ead5a1 100644 --- a/tests/functions/language_select_test.php +++ b/tests/functions/language_select_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. * */ diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index cf42fd5b58..830b52fb4c 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_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. * */ diff --git a/tests/functions/parse_cfg_file_test.php b/tests/functions/parse_cfg_file_test.php index 920fc2eaa7..449d5c3434 100644 --- a/tests/functions/parse_cfg_file_test.php +++ b/tests/functions/parse_cfg_file_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. * */ diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 96de5c5767..6f7607132e 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.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. * */ diff --git a/tests/functions/quoteattr_test.php b/tests/functions/quoteattr_test.php index 9d2a7d470e..6e191f9610 100644 --- a/tests/functions/quoteattr_test.php +++ b/tests/functions/quoteattr_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. * */ diff --git a/tests/functions/style_select_test.php b/tests/functions/style_select_test.php index 1e44f3c2cb..a918f83155 100644 --- a/tests/functions/style_select_test.php +++ b/tests/functions/style_select_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. * */ diff --git a/tests/functions/validate_data_helper.php b/tests/functions/validate_data_helper.php index b92a3aa5eb..448d029d3f 100644 --- a/tests/functions/validate_data_helper.php +++ b/tests/functions/validate_data_helper.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. * */ diff --git a/tests/functions/validate_date_test.php b/tests/functions/validate_date_test.php index 1dcd1361a2..9dc0db46d6 100644 --- a/tests/functions/validate_date_test.php +++ b/tests/functions/validate_date_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. * */ diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php index 9a6ce39251..dbd4b05520 100644 --- a/tests/functions/validate_email_test.php +++ b/tests/functions/validate_email_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. * */ diff --git a/tests/functions/validate_hex_colour_test.php b/tests/functions/validate_hex_colour_test.php index 812ebe5eeb..b2c4862458 100644 --- a/tests/functions/validate_hex_colour_test.php +++ b/tests/functions/validate_hex_colour_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. * */ diff --git a/tests/functions/validate_jabber_test.php b/tests/functions/validate_jabber_test.php index 5a53c963bd..23811a94c0 100644 --- a/tests/functions/validate_jabber_test.php +++ b/tests/functions/validate_jabber_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. * */ diff --git a/tests/functions/validate_lang_iso_test.php b/tests/functions/validate_lang_iso_test.php index c8a5b71021..81b56055e6 100644 --- a/tests/functions/validate_lang_iso_test.php +++ b/tests/functions/validate_lang_iso_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. * */ diff --git a/tests/functions/validate_match_test.php b/tests/functions/validate_match_test.php index 73a363e003..811bed3e33 100644 --- a/tests/functions/validate_match_test.php +++ b/tests/functions/validate_match_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. * */ diff --git a/tests/functions/validate_num_test.php b/tests/functions/validate_num_test.php index 4deac02ebc..798468759c 100644 --- a/tests/functions/validate_num_test.php +++ b/tests/functions/validate_num_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. * */ diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php index 82c5fa03c1..c5942e79bf 100644 --- a/tests/functions/validate_password_test.php +++ b/tests/functions/validate_password_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. * */ diff --git a/tests/functions/validate_string_test.php b/tests/functions/validate_string_test.php index ab44c28541..24026e4c9f 100644 --- a/tests/functions/validate_string_test.php +++ b/tests/functions/validate_string_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. * */ diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php index 0819974e54..dc9f685f04 100644 --- a/tests/functions/validate_username_test.php +++ b/tests/functions/validate_username_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. * */ diff --git a/tests/functions/validate_with_method_test.php b/tests/functions/validate_with_method_test.php index 86d7b9571c..37e05d412a 100644 --- a/tests/functions/validate_with_method_test.php +++ b/tests/functions/validate_with_method_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 55e1f02151adbe9d66a2d87c00c4f1959739aa36 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Wed, 28 May 2014 01:05:46 +0200 Subject: [ticket/12594] Replace phpBB Group with phpBB Limited PHPBB3-12594 --- tests/functions/parse_cfg_file_test.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/parse_cfg_file_test.php b/tests/functions/parse_cfg_file_test.php index 449d5c3434..b47e25fbc1 100644 --- a/tests/functions/parse_cfg_file_test.php +++ b/tests/functions/parse_cfg_file_test.php @@ -23,10 +23,13 @@ class phpbb_functions_parse_cfg_file extends phpbb_test_case '#', '# phpBB Style Configuration File', '#', - '# @package phpBB3', - '# @copyright (c) 2005 phpBB Group', - '# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2', + '# This file is part of the phpBB Forum Software package.', '#', + '# @copyright (c) phpBB Limited ', + '# @license GNU General Public License, version 2 (GPL-2.0)', + '#', + '# For full copyright and license information, please see', + '# the docs/CREDITS.txt file.', '#', '# At the left is the name, please do not change this', '# At the right the value is entered', @@ -39,24 +42,24 @@ class phpbb_functions_parse_cfg_file extends phpbb_test_case '', '# General Information about this style', 'name = prosilver', - 'copyright = © phpBB Group, 2007', + 'copyright = © phpBB Limited, 2007', 'version = 3.0.12', ), array( 'name' => 'prosilver', - 'copyright' => '© phpBB Group, 2007', + 'copyright' => '© phpBB Limited, 2007', 'version' => '3.0.12', ), ), array( array( 'name = subsilver2', - 'copyright = © 2005 phpBB Group', + 'copyright = © 2005 phpBB Limited', 'version = 3.0.12', ), array( 'name' => 'subsilver2', - 'copyright' => '© 2005 phpBB Group', + 'copyright' => '© 2005 phpBB Limited', 'version' => '3.0.12', ), ), -- cgit v1.2.1 From 911725a5812cff5c1a0daa37b99767b5144e8a11 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 16:59:55 +0200 Subject: [ticket/10073] Split email validation from email ban and taken checks PHPBB3-10073 --- tests/functions/validate_email_test.php | 112 --------------------------- tests/functions/validate_user_email_test.php | 106 +++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 112 deletions(-) delete mode 100644 tests/functions/validate_email_test.php create mode 100644 tests/functions/validate_user_email_test.php (limited to 'tests/functions') diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php deleted file mode 100644 index dbd4b05520..0000000000 --- a/tests/functions/validate_email_test.php +++ /dev/null @@ -1,112 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../mock/user.php'; -require_once dirname(__FILE__) . '/validate_data_helper.php'; - -class phpbb_functions_validate_email_test extends phpbb_database_test_case -{ - protected $db; - protected $user; - protected $helper; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); - } - - protected function setUp() - { - parent::setUp(); - - $this->db = $this->new_dbal(); - $this->user = new phpbb_mock_user; - $this->helper = new phpbb_functions_validate_data_helper($this); - } - - /** - * Get validation prerequesites - * - * @param bool $check_mx Whether mx records should be checked - */ - protected function set_validation_prerequisites($check_mx) - { - global $config, $db, $user; - - $config['email_check_mx'] = $check_mx; - $db = $this->db; - $user = $this->user; - $user->optionset('banned_users', array('banned@example.com')); - } - - public function test_validate_email() - { - $this->set_validation_prerequisites(false); - - $this->helper->assert_valid_data(array( - 'empty' => array( - array(), - '', - array('email'), - ), - 'allowed' => array( - array(), - 'foobar@example.com', - array('email', 'foobar@example.com'), - ), - 'invalid' => array( - array('EMAIL_INVALID'), - 'fööbar@example.com', - array('email'), - ), - 'valid_complex' => array( - array(), - "'%$~test@example.com", - array('email'), - ), - 'taken' => array( - array('EMAIL_TAKEN'), - 'admin@example.com', - array('email'), - ), - 'banned' => array( - array('EMAIL_BANNED'), - 'banned@example.com', - array('email'), - ), - )); - } - - /** - * @group slow - */ - public function test_validate_email_mx() - { - $this->set_validation_prerequisites(true); - - $this->helper->assert_valid_data(array( - 'valid' => array( - array(), - 'foobar@phpbb.com', - array('email'), - ), - 'no_mx' => array( - array('DOMAIN_NO_MX_RECORD'), - 'test@does-not-exist.phpbb.com', - array('email'), - ), - )); - } -} diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php new file mode 100644 index 0000000000..951d5794e6 --- /dev/null +++ b/tests/functions/validate_user_email_test.php @@ -0,0 +1,106 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../mock/user.php'; +require_once dirname(__FILE__) . '/validate_data_helper.php'; + +class phpbb_functions_validate_user_email_test extends phpbb_database_test_case +{ + protected $db; + protected $user; + protected $helper; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->user = new phpbb_mock_user; + $this->helper = new phpbb_functions_validate_data_helper($this); + } + + /** + * Get validation prerequesites + * + * @param bool $check_mx Whether mx records should be checked + */ + protected function set_validation_prerequisites($check_mx) + { + global $config, $db, $user; + + $config['email_check_mx'] = $check_mx; + $db = $this->db; + $user = $this->user; + $user->optionset('banned_users', array('banned@example.com')); + } + + public static function validate_user_email_data() + { + return array( + array('empty', array(), ''), + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array('EMAIL_TAKEN'), 'admin@example.com'), + array('banned', array('EMAIL_BANNED'), 'banned@example.com'), + ); + } + + /** + * @dataProvider validate_user_email_data + */ + public function test_validate_user_email($case, $errors, $email) + { + $this->set_validation_prerequisites(false); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } + + public static function validate_user_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + + /** + * @dataProvider validate_user_email_mx_data + * @group slow + */ + public function test_validate_user_email_mx($case, $errors, $email) + { + $this->set_validation_prerequisites(true); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } +} -- cgit v1.2.1 From 0108e19d2119b312d48227bca9ae23d6dd8189f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 17:00:30 +0200 Subject: [ticket/10073] Add tests for new validate_email() PHPBB3-10073 --- tests/functions/validate_email_test.php | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/functions/validate_email_test.php (limited to 'tests/functions') diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php new file mode 100644 index 0000000000..b46509fda7 --- /dev/null +++ b/tests/functions/validate_email_test.php @@ -0,0 +1,102 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->user = new phpbb_mock_user; + $this->helper = new phpbb_functions_validate_data_helper($this); + } + + /** + * Get validation prerequesites + * + * @param bool $check_mx Whether mx records should be checked + */ + protected function set_validation_prerequisites($check_mx) + { + global $config, $db, $user; + + $config['email_check_mx'] = $check_mx; + $db = $this->db; + $user = $this->user; + $user->optionset('banned_users', array('banned@example.com')); + } + + public static function validate_email_data() + { + return array( + array('empty', array('EMAIL_INVALID'), ''), // email does not allow empty + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array(), 'admin@example.com'), // email does not check taken, should use user_email instead + array('banned', array(), 'banned@example.com'), // email does not check ban, should use user_email instead + ); + } + + /** + * @dataProvider validate_email_data + */ + public function test_validate_email($case, $errors, $email) + { + $this->set_validation_prerequisites(false); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('email'), + ), + )); + } + + public static function validate_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + + /** + * @dataProvider validate_email_mx_data + * @group slow + */ + public function test_validate_email_mx($case, $errors, $email) + { + $this->set_validation_prerequisites(true); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('email'), + ), + )); + } +} -- cgit v1.2.1 From 04164affe672be6feea676fd05cf9761bf2e477a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 20 Jun 2014 12:35:42 +0200 Subject: [ticket/12747] Drop support for Firebird PHPBB3-12747 --- tests/functions/convert_30_dbms_to_31_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index 9647eb341c..a3992aef5c 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -18,7 +18,6 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case public function convert_30_dbms_to_31_data() { return array( - array('firebird'), array('mssql'), array('mssql_odbc'), array('mssqlnative'), -- 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/functions/obtain_online_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index 830b52fb4c..e793a4eb82 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -128,19 +128,19 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case { return array( array(0, false, array( - 'online_userlist' => 'REGISTERED_USERS 2, 3', + 'online_userlist' => 'REGISTERED_USERS 2, 3', 'l_online_users' => 'ONLINE_USERS_TOTAL 5 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 3', )), array(0, true, array( - 'online_userlist' => 'REGISTERED_USERS 2, 3', + 'online_userlist' => 'REGISTERED_USERS 2, 3', 'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 7 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 3 GUEST_USERS_TOTAL 2', )), array(1, false, array( - 'online_userlist' => 'BROWSING_FORUM 3', + 'online_userlist' => 'BROWSING_FORUM 3', 'l_online_users' => 'ONLINE_USERS_TOTAL 2 REG_USERS_TOTAL 1 HIDDEN_USERS_TOTAL 1', )), array(1, true, array( - 'online_userlist' => 'BROWSING_FORUM_GUESTS 1 3', + '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( -- cgit v1.2.1 From b7e1959d56a3334f730e5d0fd4194f5e4d0597a3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 7 May 2014 23:22:53 +0200 Subject: [ticket/12099] Remove config again PHPBB3-12099 --- tests/functions/build_url_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 7a70bddc71..06415a424e 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -30,10 +30,11 @@ class phpbb_build_url_test extends phpbb_test_case new phpbb_mock_request() ), new \phpbb\filesystem(), + $this->getMock('\phpbb\request\request'), $phpbb_root_path, 'php' ); - $phpbb_container->set('path_helper', $path_helper); + $phpbb_container->set('path_helper', $phpbb_path_helper); } public function build_url_test_data() { -- cgit v1.2.1 From ed812a9dfb59b1eb83263adbaa52723ff826a791 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 21:58:17 +0200 Subject: [ticket/12775] Move phpbb_convert_30_dbms_to_31 into the config file class PHPBB3-12775 --- tests/functions/convert_30_dbms_to_31_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index a3992aef5c..729c0a82f0 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -36,7 +36,8 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case { $expected = "phpbb\\db\\driver\\$input"; - $output = phpbb_convert_30_dbms_to_31($input); + $config_php_file = new \phpbb\config_php_file('', ''); + $output = $config_php_file->convert_30_dbms_to_31($input); $this->assertEquals($expected, $output); } -- cgit v1.2.1 From 0d320186cf37ae81eb038a74664440317dddc721 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 11 Jul 2014 14:33:45 -0700 Subject: [ticket/12841] Add a tests for the new function PHPBB3-12841 --- tests/functions/insert_config_array_test.php | 142 +++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 tests/functions/insert_config_array_test.php (limited to 'tests/functions') diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php new file mode 100644 index 0000000000..2ff7ae4853 --- /dev/null +++ b/tests/functions/insert_config_array_test.php @@ -0,0 +1,142 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class phpbb_functions_insert_config_array_test extends phpbb_test_case +{ + public function config_display_vars() + { + return array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ); + } + + public function insert_config_array_data() + { + return array( + array( // Add a new config after 1st array item + array('new_config_1' => array()), + array('after' => 'legend1'), + array( + 'legend1' => '', + 'new_config_1' => array(), + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config after last array item + array('new_config_1' => array()), + array('after' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + 'new_config_1' => array(), + ), + ), + array( // Add a new config before 2nd array item + array('new_config_1' => array()), + array('before' => 'acp_config_1'), + array( + 'legend1' => '', + 'new_config_1' => array(), + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config before last config item + array('new_config_1' => array()), + array('before' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'new_config_1' => array(), + 'acp_config_5' => array(), + ), + ), + array( // When an array key does not exist + array('new_config_1' => array()), + array('after' => 'foobar'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // When before|after is not used correctly (defaults to before) + array('new_config_1' => array()), + array('foobar' => 'acp_config_1'), + array( + 'legend1' => '', + 'new_config_1' => array(), + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config set after the last array item + array( + 'legend2' => array(), + 'new_config_1' => array(), + 'new_config_2' => array(), + 'new_config_3' => array(), + ), + array('after' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + 'legend2' => array(), + 'new_config_1' => array(), + 'new_config_2' => array(), + 'new_config_3' => array(), + ), + ), + ); + } + + /** + * @dataProvider insert_config_array_data + */ + public function test_insert_config_array($new_config, $position, $expected) + { + $config_array = $this->config_display_vars(); + $new_config_array = insert_config_array($config_array, $new_config, $position); + + $this->assertSame($expected, $new_config_array); + } +} -- cgit v1.2.1 From 056584680b4603e93c5e428a1177b09fbea88f30 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 24 Jul 2014 07:44:35 -0700 Subject: [ticket/12841] prefix function name with phpbb_ PHPBB3-12841 --- tests/functions/insert_config_array_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php index 2ff7ae4853..8034ce982d 100644 --- a/tests/functions/insert_config_array_test.php +++ b/tests/functions/insert_config_array_test.php @@ -135,7 +135,7 @@ class phpbb_functions_insert_config_array_test extends phpbb_test_case public function test_insert_config_array($new_config, $position, $expected) { $config_array = $this->config_display_vars(); - $new_config_array = insert_config_array($config_array, $new_config, $position); + $new_config_array = phpbb_insert_config_array($config_array, $new_config, $position); $this->assertSame($expected, $new_config_array); } -- cgit v1.2.1 From 6576e0eb88908b40174dd64cbcb6842011afd91e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 27 Jul 2014 23:03:43 -0500 Subject: [ticket/12841] Update comments in tests making after default PHPBB3-12841 --- tests/functions/insert_config_array_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php index 8034ce982d..e0ea3428b8 100644 --- a/tests/functions/insert_config_array_test.php +++ b/tests/functions/insert_config_array_test.php @@ -92,7 +92,7 @@ class phpbb_functions_insert_config_array_test extends phpbb_test_case 'acp_config_5' => array(), ), ), - array( // When before|after is not used correctly (defaults to before) + array( // When after|before is not used correctly (defaults to before) array('new_config_1' => array()), array('foobar' => 'acp_config_1'), array( -- cgit v1.2.1 From ced76b5f4daed59f7b58fadc8c955c7b76373cf5 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 28 Jul 2014 22:27:01 -0500 Subject: [ticket/12841] Make config position default to after PHPBB3-12841 --- tests/functions/insert_config_array_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php index e0ea3428b8..bfcb05862e 100644 --- a/tests/functions/insert_config_array_test.php +++ b/tests/functions/insert_config_array_test.php @@ -92,13 +92,13 @@ class phpbb_functions_insert_config_array_test extends phpbb_test_case 'acp_config_5' => array(), ), ), - array( // When after|before is not used correctly (defaults to before) + array( // When after|before is not used correctly (defaults to after) array('new_config_1' => array()), array('foobar' => 'acp_config_1'), array( 'legend1' => '', - 'new_config_1' => array(), 'acp_config_1' => array(), + 'new_config_1' => array(), 'acp_config_2' => array(), 'acp_config_3' => array(), 'acp_config_4' => array(), -- cgit v1.2.1 From 8d99b4afe1557a6ec0e760c4876bb06a3b9991d3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 10 Aug 2014 13:40:27 +0200 Subject: [ticket/12932] Fix tests and calls to create_datetime PHPBB3-12932 --- tests/functions/generate_string_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index 32a04c1501..cd1e37618a 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.php @@ -22,7 +22,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case { parent::setUp(); - $this->user = new \phpbb\user(); + $this->user = new \phpbb\user('\phpbb\datetime'); $this->user->data = array('user_lang' => 'en'); $this->user->add_lang('common'); } -- cgit v1.2.1 From 6fd54436ee4568cd2e70d08063a816e3ce1ff4bc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Sep 2014 13:50:56 +0200 Subject: [ticket/13073] Add path regex to get_preg_expression() and add unit tests We're now calling get_preg_expression() instead of hardcoding the regex into the helper route method. PHPBB3-13073 --- tests/functions/get_preg_expression_test.php | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/functions/get_preg_expression_test.php (limited to 'tests/functions') diff --git a/tests/functions/get_preg_expression_test.php b/tests/functions/get_preg_expression_test.php new file mode 100644 index 0000000000..ed0f2b5685 --- /dev/null +++ b/tests/functions/get_preg_expression_test.php @@ -0,0 +1,38 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_functions_get_preg_expression_test extends phpbb_test_case +{ + public function data_path_remove_dot_trailing_slash() + { + return array( + array('/..', '$2', './../'), + array('/..', '$2', '/../'), + array('', '$2', ''), + array('', '$2', './'), + array('', '$2', '/'), + array('/../..', '$2', './../../'), + array('/../..', '$2', '/../../'), + ); + } + + /** + * @dataProvider data_path_remove_dot_trailing_slash + */ + public function test_path_remove_dot_trailing_slash($expected, $replace, $input) + { + $this->assertSame($expected, preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), $replace, $input)); + } +} -- cgit v1.2.1 From d720428564ee1982c3087a9433304d630c7d26af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Sep 2014 15:30:24 +0200 Subject: [ticket/13073] Switch $input with $expected and add paths with letters PHPBB3-13073 --- tests/functions/get_preg_expression_test.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/get_preg_expression_test.php b/tests/functions/get_preg_expression_test.php index ed0f2b5685..e74017d315 100644 --- a/tests/functions/get_preg_expression_test.php +++ b/tests/functions/get_preg_expression_test.php @@ -18,20 +18,22 @@ class phpbb_functions_get_preg_expression_test extends phpbb_test_case public function data_path_remove_dot_trailing_slash() { return array( - array('/..', '$2', './../'), - array('/..', '$2', '/../'), + array('./../', '$2', '/..'), + array('/../', '$2', '/..'), array('', '$2', ''), - array('', '$2', './'), - array('', '$2', '/'), - array('/../..', '$2', './../../'), - array('/../..', '$2', '/../../'), + array('./', '$2', ''), + array('/', '$2', ''), + array('./../../', '$2', '/../..'), + array('/../../', '$2', '/../..'), + array('./dir/', '$2', '/dir'), + array('./../dir/', '$2', '/../dir'), ); } /** * @dataProvider data_path_remove_dot_trailing_slash */ - public function test_path_remove_dot_trailing_slash($expected, $replace, $input) + public function test_path_remove_dot_trailing_slash($input, $replace, $expected) { $this->assertSame($expected, preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), $replace, $input)); } -- cgit v1.2.1 From 6fd092b5df6f96530fec8ba1aec426b6d59b822b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 3 Nov 2014 16:24:09 +0100 Subject: [ticket/13280] Correctly format user page for build_url() PHPBB3-13280 --- tests/functions/build_url_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 06415a424e..df178f277e 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -79,9 +79,16 @@ class phpbb_build_url_test extends phpbb_test_case { global $user, $phpbb_root_path; - $user->page['page'] = $page; + $user->page['page'] = str_replace('%2F', '/', urlencode($this->sanitizer($page))); $output = build_url($strip_vars); $this->assertEquals($expected, $output); } + + protected function sanitizer($value) + { + $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper->set_var($value, $value, gettype($value), true); + return $value; + } } -- cgit v1.2.1 From 13b59af1ffd0af652ba0ce3bc3f2594fc448fdb5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 3 Nov 2014 17:14:18 +0100 Subject: [ticket/13280] Add additional sanitizer for ampersands in server superglobal PHPBB3-13280 --- tests/functions/build_url_test.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index df178f277e..5cfd1300de 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -69,6 +69,11 @@ class phpbb_build_url_test extends phpbb_test_case array('f', 'style', 't'), 'http://test.phpbb.com/viewtopic.php?', ), + array( + 'posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', + false, + 'phpBB/posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', + ) ); } @@ -79,16 +84,10 @@ class phpbb_build_url_test extends phpbb_test_case { global $user, $phpbb_root_path; - $user->page['page'] = str_replace('%2F', '/', urlencode($this->sanitizer($page))); + $user->page['page'] = $page; + $output = build_url($strip_vars); $this->assertEquals($expected, $output); } - - protected function sanitizer($value) - { - $type_cast_helper = new \phpbb\request\type_cast_helper(); - $type_cast_helper->set_var($value, $value, gettype($value), true); - return $value; - } } -- cgit v1.2.1 From 483af1d036aadf8bd7d3b4c76a1fe97409238547 Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 6 Nov 2014 12:25:36 +0700 Subject: [ticket/13297] Add unicode modifier to url/email regular expression patterns. PHPBB3-13297 --- tests/functions/make_clickable_test.php | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/functions/make_clickable_test.php (limited to 'tests/functions') diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php new file mode 100644 index 0000000000..e61cb2c30e --- /dev/null +++ b/tests/functions/make_clickable_test.php @@ -0,0 +1,100 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; + +class phpbb_functions_make_clickable_test extends phpbb_test_case +{ + /** + * Tags: + * 'm' - full URL like xxxx://aaaaa.bbb.cccc. + * 'l' - local relative board URL like http://domain.tld/path/to/board/index.php + * 'w' - URL without http/https protocol like www.xxxx.yyyy[/zzzz] aka 'lazy' URLs + * 'e' - email@domain type address + * + * Classes: + * "postlink-local" for 'l' URLs + * "postlink" for the rest of URLs + * empty for email addresses + **/ + public function data_test_make_clickable_url_positive() + { + return array( + array( + 'http://www.phpbb.com/community/', + '
http://www.phpbb.com/community/' + ), + array( + 'http://www.phpbb.com/path/file.ext#section', + 'http://www.phpbb.com/path/file.ext#section' + ), + array( + 'ftp://ftp.phpbb.com/', + 'ftp://ftp.phpbb.com/' + ), + array( + 'sip://bantu@phpbb.com', + 'sip://bantu@phpbb.com' + ), + array( + 'www.phpbb.com/community/', + 'www.phpbb.com/community/' + ), + array( + 'http://testhost/viewtopic.php?t=1', + 'viewtopic.php?t=1' + ), + array( + 'email@domain.com', + 'email@domain.com' + ), + // Test appending punctuation mark to the URL + array( + 'http://testhost/viewtopic.php?t=1!', + 'viewtopic.php?t=1!' + ), + array( + 'www.phpbb.com/community/?', + 'www.phpbb.com/community/?' + ), + // Test shortened text for URL > 55 characters long + // URL text should be turned into: first 39 chars + ' ... ' + last 10 chars + array( + 'http://www.phpbb.com/community/path/to/long/url/file.ext#section', + 'http://www.phpbb.com/community/path/to/ ... xt#section' + ), + + // IDN is not parsed and returned as is + array('http://домен.рф', 'http://домен.рф'), + array('почта@домен.рф', 'почта@домен.рф'), + ); + } + + protected function setUp() + { + parent::setUp(); + + global $config, $user, $request; + $user = new phpbb_mock_user(); + $request = new phpbb_mock_request(); + } + + /** + * @dataProvider data_test_make_clickable_url_positive + */ + public function test_urls_matching_positive($url, $expected) + { + $this->assertSame($expected, make_clickable($url)); + } +} -- cgit v1.2.1 From 6d533d2f8630d5bed2bfdbfd09cc9c689fbad1b5 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 12 Nov 2014 10:30:27 +0100 Subject: [ticket/13280] Revert "Merge pull request #3107 from marc1706/ticket/13280" This reverts commit a1b58d05d158ff7afd789c1b27821e17198f8d58, reversing changes made to 0e772afb9db640e54e84cfccaddcf74f3edbb3fb. PHPBB3-13280 --- tests/functions/build_url_test.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 5cfd1300de..06415a424e 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -69,11 +69,6 @@ class phpbb_build_url_test extends phpbb_test_case array('f', 'style', 't'), 'http://test.phpbb.com/viewtopic.php?', ), - array( - 'posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', - false, - 'phpBB/posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', - ) ); } @@ -85,7 +80,6 @@ class phpbb_build_url_test extends phpbb_test_case global $user, $phpbb_root_path; $user->page['page'] = $page; - $output = build_url($strip_vars); $this->assertEquals($expected, $output); -- cgit v1.2.1 From 526a97db7cea84ab54b7d283c888ada58a310bc4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 12 Nov 2014 11:47:23 +0100 Subject: [ticket/13280] Add new tests PHPBB3-13280 --- tests/functions/build_url_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/functions') diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 06415a424e..a59b94c744 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -69,6 +69,11 @@ class phpbb_build_url_test extends phpbb_test_case array('f', 'style', 't'), 'http://test.phpbb.com/viewtopic.php?', ), + array( + 'posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', + false, + 'phpBB/posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E', + ) ); } -- cgit v1.2.1 From a918abe113fc85cad4d0e0778b815279b00062b9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Nov 2014 01:22:30 +0100 Subject: [ticket/13338] Move insert_config_array_test to functions_acp, add deps. PHPBB3-13338 --- tests/functions/insert_config_array_test.php | 142 --------------------------- 1 file changed, 142 deletions(-) delete mode 100644 tests/functions/insert_config_array_test.php (limited to 'tests/functions') diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php deleted file mode 100644 index bfcb05862e..0000000000 --- a/tests/functions/insert_config_array_test.php +++ /dev/null @@ -1,142 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -class phpbb_functions_insert_config_array_test extends phpbb_test_case -{ - public function config_display_vars() - { - return array( - 'legend1' => '', - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - ); - } - - public function insert_config_array_data() - { - return array( - array( // Add a new config after 1st array item - array('new_config_1' => array()), - array('after' => 'legend1'), - array( - 'legend1' => '', - 'new_config_1' => array(), - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - ), - ), - array( // Add a new config after last array item - array('new_config_1' => array()), - array('after' => 'acp_config_5'), - array( - 'legend1' => '', - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - 'new_config_1' => array(), - ), - ), - array( // Add a new config before 2nd array item - array('new_config_1' => array()), - array('before' => 'acp_config_1'), - array( - 'legend1' => '', - 'new_config_1' => array(), - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - ), - ), - array( // Add a new config before last config item - array('new_config_1' => array()), - array('before' => 'acp_config_5'), - array( - 'legend1' => '', - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'new_config_1' => array(), - 'acp_config_5' => array(), - ), - ), - array( // When an array key does not exist - array('new_config_1' => array()), - array('after' => 'foobar'), - array( - 'legend1' => '', - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - ), - ), - array( // When after|before is not used correctly (defaults to after) - array('new_config_1' => array()), - array('foobar' => 'acp_config_1'), - array( - 'legend1' => '', - 'acp_config_1' => array(), - 'new_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - ), - ), - array( // Add a new config set after the last array item - array( - 'legend2' => array(), - 'new_config_1' => array(), - 'new_config_2' => array(), - 'new_config_3' => array(), - ), - array('after' => 'acp_config_5'), - array( - 'legend1' => '', - 'acp_config_1' => array(), - 'acp_config_2' => array(), - 'acp_config_3' => array(), - 'acp_config_4' => array(), - 'acp_config_5' => array(), - 'legend2' => array(), - 'new_config_1' => array(), - 'new_config_2' => array(), - 'new_config_3' => array(), - ), - ), - ); - } - - /** - * @dataProvider insert_config_array_data - */ - public function test_insert_config_array($new_config, $position, $expected) - { - $config_array = $this->config_display_vars(); - $new_config_array = phpbb_insert_config_array($config_array, $new_config, $position); - - $this->assertSame($expected, $new_config_array); - } -} -- cgit v1.2.1 From 21c8985fe85d54facc9dce59f6b7cbd293b21ade Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Nov 2014 01:35:13 +0100 Subject: [ticket/13338] Add include statements for dependencies. PHPBB3-13338 --- tests/functions/validate_username_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functions') diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php index dc9f685f04..4fa5af7ff3 100644 --- a/tests/functions/validate_username_test.php +++ b/tests/functions/validate_username_test.php @@ -11,6 +11,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; -- cgit v1.2.1 From a8c62e707af0971a62b7601f4ac6ea46f57b16c2 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 25 Nov 2014 22:16:30 +0700 Subject: [ticket/12926] Support for IDN (IRI) Add international domain name support for URLs. PHPBB3-12926 --- tests/functions/make_clickable_test.php | 84 ++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) (limited to 'tests/functions') diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index e61cb2c30e..63beeb06b2 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -74,13 +74,77 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case 'http://www.phpbb.com/community/path/to/long/url/file.ext#section', 'http://www.phpbb.com/community/path/to/ ... xt#section' ), + ); + } - // IDN is not parsed and returned as is - array('http://домен.рф', 'http://домен.рф'), + public function data_test_make_clickable_url_idn() + { + return array( + array( + 'http://www.täst.de/community/', + 'http://www.täst.de/community/' + ), + array( + 'http://www.täst.de/path/file.ext#section', + 'http://www.täst.de/path/file.ext#section' + ), + array( + 'ftp://ftp.täst.de/', + 'ftp://ftp.täst.de/' + ), + array( + 'sip://bantu@täst.de', + 'sip://bantu@täst.de' + ), + array( + 'www.täst.de/community/', + 'www.täst.de/community/' + ), + // Test appending punctuation mark to the URL + array( + 'http://домен.рф/viewtopic.php?t=1!', + 'http://домен.рф/viewtopic.php?t=1!' + ), + array( + 'www.домен.рф/сообщество/?', + 'www.домен.рф/сообщество/?' + ), + // Test shortened text for URL > 55 characters long + // URL text should be turned into: first 39 chars + ' ... ' + last 10 chars + array( + 'http://www.домен.рф/сообщество/путь/по/длинной/ссылке/file.ext#section', + 'http://www.домен.рф/сообщество/путь/по/ ... xt#section' + ), + + // IDN with invalid characters shouldn't be parsed correctly (only 'valid' part) + array( + 'http://www.täst╫.de', + 'http://www.täst╫.de' + ), + // IDN in emails is unsupported yet array('почта@домен.рф', 'почта@домен.рф'), ); } + public function data_test_make_clickable_local_url_idn() + { + return array( + array( + 'http://www.домен.рф/viewtopic.php?t=1', + 'viewtopic.php?t=1' + ), + // Test appending punctuation mark to the URL + array( + 'http://www.домен.рф/viewtopic.php?t=1!', + 'viewtopic.php?t=1!' + ), + array( + 'http://www.домен.рф/сообщество/?', + 'сообщество/?' + ), + ); + } + protected function setUp() { parent::setUp(); @@ -97,4 +161,20 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case { $this->assertSame($expected, make_clickable($url)); } + + /** + * @dataProvider data_test_make_clickable_url_idn + */ + public function test_urls_matching_idn($url, $expected) + { + $this->assertSame($expected, make_clickable($url)); + } + + /** + * @dataProvider data_test_make_clickable_local_url_idn + */ + public function test_local_urls_matching_idn($url, $expected) + { + $this->assertSame($expected, make_clickable($url, "http://www.домен.рф")); + } } -- cgit v1.2.1 From b2674cf1f612dd03dc3b11173462007caf08d187 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Jan 2015 20:14:45 +0100 Subject: [ticket/13543] Fix broken slow test PHPBB3-13543 --- tests/functions/get_remote_file_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/functions') diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index d412dce164..612d82273e 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_test.php @@ -21,6 +21,10 @@ class phpbb_functions_get_remote_file extends phpbb_test_case { public function test_version_phpbb_com() { + global $phpbb_container; + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('file_downloader', new \phpbb\file_downloader()); + $hostname = 'version.phpbb.com'; if (!phpbb_checkdnsrr($hostname, 'A')) -- cgit v1.2.1 From 950c72a8a578905b3c08b7fdf6f1a0df2a09f384 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 17 Feb 2015 21:03:39 +0700 Subject: [ticket/13433] Add make_clickable() test for emails PHPBB3-13433 --- tests/functions/make_clickable_email_test.php | 222 ++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 tests/functions/make_clickable_email_test.php (limited to 'tests/functions') diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php new file mode 100644 index 0000000000..4c802d0487 --- /dev/null +++ b/tests/functions/make_clickable_email_test.php @@ -0,0 +1,222 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; + +class phpbb_functions_make_clickable_email_test extends phpbb_test_case +{ + protected function setUp() + { + parent::setUp(); + + global $config, $user, $request; + $user = new phpbb_mock_user(); + $request = new phpbb_mock_request(); + } + + /** + * 'e' tag for email addresses html + **/ + public function data_test_make_clickable_email_positive() + { + return array( + array( + 'nobody@phpbb.com', + 'nobody@phpbb.com' + ), + array( + 'Nobody@sub.phpbb.com', + 'Nobody@sub.phpbb.com' + ), + array( + 'alice.bob@foo.phpbb.com', + 'alice.bob@foo.phpbb.com' + ), + array( + 'alice-foo@bar.phpbb.com', + 'alice-foo@bar.phpbb.com' + ), + array( + 'alice_foo@bar.phpbb.com', + 'alice_foo@bar.phpbb.com' + ), + array( + 'alice+tag@foo.phpbb.com', + 'alice+tag@foo.phpbb.com' + ), + array( + 'alice&tag@foo.phpbb.com', + 'alice&tag@foo.phpbb.com' + ), + array( + 'alice@phpbb.australia', + 'alice@phpbb.australia' + ), + + // Test shortened text for email > 55 characters long + // Email text should be turned into: first 39 chars + ' ... ' + last 10 chars + array( + 'alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlong', + 'alice@phpbb.topZlevelZdomainZnamesZcanZ ... ctersZlong' + ), + array( + 'l3tt3rsAndNumb3rs@domain.com', + 'l3tt3rsAndNumb3rs@domain.com' + ), + array( + 'has-dash@domain.com', + 'has-dash@domain.com' + ), + array( + 'hasApostrophe.o\'leary@domain.org', + 'hasApostrophe.o\'leary@domain.org' + ), + array( + 'uncommonTLD@domain.museum', + 'uncommonTLD@domain.museum' + ), + array( + 'uncommonTLD@domain.travel', + 'uncommonTLD@domain.travel' + ), + array( + 'uncommonTLD@domain.mobi', + 'uncommonTLD@domain.mobi' + ), + array( + 'countryCodeTLD@domain.uk', + 'countryCodeTLD@domain.uk' + ), + array( + 'countryCodeTLD@domain.rw', + 'countryCodeTLD@domain.rw' + ), + array( + 'numbersInDomain@911.com', + 'numbersInDomain@911.com' + ), + array( + 'underscore_inLocal@domain.net', + 'underscore_inLocal@domain.net' + ), + array( + 'IPInsteadOfDomain@127.0.0.1', + 'IPInsteadOfDomain@127.0.0.1' + ), + array( + 'IPAndPort@127.0.0.1:25', + 'IPAndPort@127.0.0.1:25' + ), + array( + 'subdomain@sub.domain.com', + 'subdomain@sub.domain.com' + ), + array( + 'local@dash-inDomain.com', + 'local@dash-inDomain.com' + ), + array( + 'dot.inLocal@foo.com', + 'dot.inLocal@foo.com' + ), + array( + 'a@singleLetterLocal.org', + 'a@singleLetterLocal.org' + ), + array( + 'singleLetterDomain@x.org', + 'singleLetterDomain@x.org' + ), + array( + '&*=?^+{}\'~@validCharsInLocal.net', + '&*=?^+{}\'~@validCharsInLocal.net' + ), + array( + 'foor@bar.newTLD', + 'foor@bar.newTLD' + ), + ); + } + + public function data_test_make_clickable_email_negative() + { + return array( + array('foo.example.com'), // @ is missing + array('.foo.example.com'), // . as first character + array('Foo.@example.com'), // . is last in local part + array('foo..123@example.com'), // . doubled + array('a@b@c@example.com'), // @ doubled + + // Emails with invalid characters + // (only 'valid' pieces having localparts prepended with one of the \n \t ( > chars should parsed if any) + array('()[]\;:,<>@example.com'), // invalid characters + array('abc(def@example.com', 'abc(def@example.com'), // invalid character ( + array('abc)def@example.com'), // invalid character ) + array('abc[def@example.com'), // invalid character [ + array('abc]def@example.com'), // invalid character ] + array('abc\def@example.com'), // invalid character \ + array('abc;def@example.com'), // invalid character ; + array('abc:def@example.com'), // invalid character : + array('abc,def@example.com'), // invalid character , + array('abcdef@example.com', 'abc>def@example.com'), // invalid character > + + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php + array('missingDomain@.com'), + array('@missingLocal.org'), + array('missingatSign.net'), + array('missingDot@com'), + array('two@@signs.com'), + // Trailing colon is ignored + array('colonButNoPort@127.0.0.1:', 'colonButNoPort@127.0.0.1:'), + + array(''), + // Trailing part after the 3rd dot is ignored + array('someone-else@127.0.0.1.26', 'someone-else@127.0.0.1.26'), + + array('.localStartsWithDot@domain.com'), + array('localEndsWithDot.@domain.com'), + array('two..consecutiveDots@domain.com'), + array('domainStartsWithDash@-domain.com'), + array('domainEndsWithDash@domain-.com'), + array('numbersInTLD@domain.c0m'), + array('missingTLD@domain.'), + array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'), + array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'), + array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'), + // The domain zone name part after the 63rd char is ignored + array( + 'alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlongZ', + 'alice@phpbb.topZlevelZdomainZnamesZcanZ ... ctersZlongZ' + ), + ); + } + + /** + * @dataProvider data_test_make_clickable_email_positive + */ + public function test_email_matching_positive($email, $expected) + { + $this->assertSame($expected, make_clickable($email)); + } + + /** + * @dataProvider data_test_make_clickable_email_negative + */ + public function test_email_matching_negative($email, $expected = null) + { + $expected = ($expected) ?: $email; + $this->assertSame($expected, make_clickable($email)); + } +} -- cgit v1.2.1 From c5178a19b244c15ff0ca5445972c7efc93c54ac4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 Apr 2015 15:48:24 +0200 Subject: [ticket/13564] Add tests for unlinking account upon deleting user PHPBB3-13564 --- tests/functions/fixtures/user_delete.xml | 46 +++++++++++++ tests/functions/user_delete_test.php | 112 +++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 tests/functions/fixtures/user_delete.xml create mode 100644 tests/functions/user_delete_test.php (limited to 'tests/functions') diff --git a/tests/functions/fixtures/user_delete.xml b/tests/functions/fixtures/user_delete.xml new file mode 100644 index 0000000000..4c4479d29b --- /dev/null +++ b/tests/functions/fixtures/user_delete.xml @@ -0,0 +1,46 @@ + + + + user_id + username_clean + username + user_permissions + user_sig + + 1 + anonymous + anonymous + + + + + 2 + 2 + 2 + + + +
+ + user_id + provider + oauth_provider_id + + 2 + google + 1234567890123456789 + +
+ + user_id + session_id + provider + oauth_token + + 2 + 897a897b797c8789997d7979879 + auth.provider.oauth.service.google + {"accessToken":"ya29.YPHwCWVkrvwu1kgbYKiDNYaQ451ZuHy9OEQAGVME8if-WBzR-v7a9ftxbx41kaL)5VLEXB-6qJEvri","endOfLife":1429959670,"extraParams":{"token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImupZCI6IjE0YuRjNzc2MDQwYjUyNDZmNTI5OWFkZDVlMmQ1NWNOPTdjMDdlZTAifQ.eyJpc3MiOiJhY2NvdW90cy5nb78nbGUuY29tIiwic3ViIjoiMTExMDMwNwerNjM4MTM5NTQwMTM1IiwiYXpwIjoiOTk3MzUwMTY0NzE0LWhwOXJrYjZpcjM4MW80YjV1NjRpaGtmM29zMnRvbWxhLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJtYXJjLmFsZXhhbmRlci4zN0BnbWFpbC5jb20iLCJhdF9oYXNoIjoiWHk2b1JabnVZUWRfRTZDeDV0RkItdyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdWQiOiI5OTczNTAxNjQ3MTQtaHA5cmtiNmlyMzgxbzRiNXU2NGloa2Yzb3MydG9tbGEuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJpYXQiOjE0Mjk5NTYwNzEsImV4cCI6MTQyOTk1OTY3MX0.C5gfSzjqwlRRvVMuTP6jfWIuEHMXn55oYHsSA3eh97n2BZL0TZHhUm4K206Fgucd6ufAphan4l0J7y6tMAHLZPr-kk6KDINxWnPG-up99reblGutay0lRYjMCcrhJAOql8EI1bi84GyliZFYHL67pE0ZtSf-CMb1CeH18TFe-Fk"},"refreshToken":null,"token_class":"OAuth\\\\OAuth2\\\\Token\\\\StdOAuth2Token"} + +
+
diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php new file mode 100644 index 0000000000..db52dcded7 --- /dev/null +++ b/tests/functions/user_delete_test.php @@ -0,0 +1,112 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; + +class phpbb_functions_user_delete_test extends phpbb_database_test_case +{ + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_delete.xml'); + } + + protected function setUp() + { + parent::setUp(); + + global $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user; + + $this->db = $db = $this->new_dbal(); + $user = new \phpbb\user('\phpbb\datetime'); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $config = new \phpbb\config\config(array( + 'auth_method' => 'oauth', + 'auth_oauth_google_key' => 'foo', + 'auth_oauth_google_secret' => 'bar', + )); + set_config_count('foobar', 0, false, $config); + $cache = new \phpbb\cache\driver\null(); + $request = new phpbb_mock_request(); + $notification_manager = new phpbb_mock_notification_manager(); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); + $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); + $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); + + $driver_helper = new \phpbb\passwords\driver\helper($config); + $passwords_drivers = array( + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), + ); + + $passwords_helper = new \phpbb\passwords\helper; + // Set up passwords manager + $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + + $oauth_provider = new \phpbb\auth\provider\oauth\oauth( + $db, + $config, + $passwords_manager, + $request, + $user, + 'phpbb_oauth_tokens', + 'phpbb_oauth_accounts', + $oauth_provider_collection, + 'phpbb_users', + $phpbb_container, + $this->phpbb_root_path, + $this->php_ext + ); + $provider_collection->offsetSet('auth.provider.oauth', $oauth_provider); + + $phpbb_container->set('auth.provider.oauth', $oauth_provider); + $phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google); + $phpbb_container->set('auth.provider_collection', $provider_collection); + $phpbb_container->set('notification_manager', $notification_manager); + } + + public function test_user_delete() + { + // Check that user is linked + $sql = 'SELECT ot.user_id AS user_id + FROM phpbb_oauth_accounts oa, phpbb_oauth_tokens ot + WHERE oa.user_id = 2 + AND ot.user_id = oa.user_id'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals(array('user_id' => '2'), $row); + + // user_delete() should return false + $this->assertFalse(user_delete('remove', array(2))); + + // Make sure user link was removed + $sql = 'SELECT ot.user_id AS user_id + FROM phpbb_oauth_accounts oa, phpbb_oauth_tokens ot + WHERE oa.user_id = 2 + AND ot.user_id = oa.user_id'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEmpty($row); + } +} -- cgit v1.2.1 From df0388ccc5b24cfb67078dd2fa8cb2fc4f607dac Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 17 Oct 2016 13:15:57 +0200 Subject: [ticket/14825] Add core.auth_oauth_(login/link)_after PHPBB3-14825 --- tests/functions/user_delete_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functions') diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index db52dcded7..c224323273 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -71,6 +71,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $oauth_provider_collection, 'phpbb_users', $phpbb_container, + $phpbb_dispatcher, $this->phpbb_root_path, $this->php_ext ); -- cgit v1.2.1