From dd35092476ec9525ba6f6352241847f040e65187 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 15 Feb 2015 08:16:59 +0200 Subject: [ci skip] Fix a PHP7 BC break in a test that wouldn't even run --- tests/codeigniter/core/compat/password_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php index c37c6ac0c..8a507d14a 100644 --- a/tests/codeigniter/core/compat/password_test.php +++ b/tests/codeigniter/core/compat/password_test.php @@ -132,7 +132,7 @@ class password_test extends CI_TestCase { $this->assertFalse(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3))); // invalid: different (lower) cost - $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 09))); + $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 9))); // invalid: different (higher) cost $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11))); -- cgit v1.2.3-24-g4f1b From af8665d973e63ace812ab1d433ae8b8dce5922c4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 17 Feb 2015 15:57:47 +0200 Subject: Fix #3572: CI_Security::_remove_evil_attributes() --- tests/codeigniter/core/Security_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 402422ff8..d967613b5 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -79,6 +79,18 @@ class Security_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_remove_evil_attributes() + { + $this->assertEquals('', $this->security->remove_evil_attributes('', false)); + $this->assertEquals('', $this->security->remove_evil_attributes('', false)); + $this->assertEquals('', $this->security->remove_evil_attributes('', false)); + $this->assertEquals('', $this->security->remove_evil_attributes('', false)); + $this->assertEquals('onOutsideOfTag=test', $this->security->remove_evil_attributes('onOutsideOfTag=test', false)); + $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', false)); + } + + // -------------------------------------------------------------------- + public function test_xss_hash() { $this->assertEmpty($this->security->xss_hash); -- cgit v1.2.3-24-g4f1b From 4b25348e06a7587c64b97811208352c5c9478ab8 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 1 Mar 2015 23:21:44 -0500 Subject: test_strip_omage_tags Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Security_test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index d967613b5..bf1714622 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -126,5 +126,24 @@ class Security_test extends CI_TestCase { $this->assertEquals('foo', $safe_filename); } + + // -------------------------------------------------------------------- + public function test_strip_image_tags() + { + $imgtags = Array( + 'Smiley face', + '' + ); + + $urls = Array( + 'smiley.gif', + 'http://www.w3schools.com/images/w3schools_green.jpg' + ); + + for($i = 0; $i < count($imgtags); $i++) + { + $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); + } + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 588a0e3774d1397b9cd0b5f9d0ba2f4793243267 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Thu, 5 Mar 2015 11:03:48 -0500 Subject: adding more img tags Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Security_test.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index bf1714622..c96eecf02 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -133,12 +133,24 @@ class Security_test extends CI_TestCase { { $imgtags = Array( 'Smiley face', - '' + 'Smiley face', + '', + '', + 'MD Logo', + '', + '', + '' ); $urls = Array( 'smiley.gif', - 'http://www.w3schools.com/images/w3schools_green.jpg' + 'smiley.gif', + 'http://www.w3schools.com/images/w3schools_green.jpg', + '/img/sunset.gif', + 'mdn-logo-sm.png', + '', + '', + '' ); for($i = 0; $i < count($imgtags); $i++) -- cgit v1.2.3-24-g4f1b From c7533fc1b25eda818b371967be97a26e275e55c5 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 9 Mar 2015 19:02:27 -0400 Subject: Update Security Unit test Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Security_test.php | 94 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 3 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index c96eecf02..7d415131b 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -45,7 +45,7 @@ class Security_test extends CI_TestCase { $this->assertInstanceOf('CI_Security', $this->security->csrf_verify()); } - + // -------------------------------------------------------------------- public function test_get_csrf_hash() @@ -70,13 +70,70 @@ class Security_test extends CI_TestCase { $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_string); } + + // -------------------------------------------------------------------- + + public function test_xss_clean_string_array() + { + $harm_strings = array( + "Hello, i try to your site", + "Simple clean string", + "Hello, i try to your site" + ); + + $harmless_strings = $this->security->xss_clean($harm_strings); + + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[0]); + $this->assertEquals("Simple clean string", $harmless_strings[1]); + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[2]); + } + + // -------------------------------------------------------------------- + + public function test_xss_clean_image_valid() + { + $harm_string = ''; + + $xss_clean_return = $this->security->xss_clean($harm_string, TRUE); + $this->assertTrue($xss_clean_return); + } + + // -------------------------------------------------------------------- + + public function test_xss_clean_image_invalid() + { + $harm_string = ''; + + $xss_clean_return = $this->security->xss_clean($harm_string, TRUE); + + $this->assertFalse($xss_clean_return); + } + + // -------------------------------------------------------------------- + public function test_xss_clean_entity_double_encoded() { $input = 'Clickhere'; $this->assertEquals('Clickhere', $this->security->xss_clean($input)); } - + + // -------------------------------------------------------------------- + + public function test_xss_clean_js_img_removal() + { + $input = 'Clickhere'; + $this->assertEquals('', $this->security->xss_clean($input)); + } + + // -------------------------------------------------------------------- + + public function test_xss_clean_sanitize_naughty_html() + { + $input = ''; + $this->assertEquals('<blink>', $this->security->xss_clean($input)); + } + // -------------------------------------------------------------------- public function test_remove_evil_attributes() @@ -101,7 +158,19 @@ class Security_test extends CI_TestCase { $this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- + + public function test_get_random_bytes() + { + $length = "invalid"; + $this->assertFalse($this->security->get_random_bytes($length)); + + + $length = 10; + $this->assertNotEmpty($this->security->get_random_bytes($length)); + } + + // -------------------------------------------------------------------- public function test_entity_decode() { @@ -158,4 +227,23 @@ class Security_test extends CI_TestCase { $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); } } + + // -------------------------------------------------------------------- + + public function test_csrf_set_hash() + { + // Set cookie for security test + $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE)); + + // Set config for Security class + $this->ci_set_config('csrf_protection', TRUE); + $this->ci_set_config('csrf_token_name', 'ci_csrf_token'); + + // leave csrf_cookie_name as blank to test _csrf_set_hash function + $this->ci_set_config('csrf_cookie_name', ''); + + $this->security = new Mock_Core_Security(); + + $this->assertNotEmpty($this->security->get_csrf_hash()); + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 34eca8aa7ffbbacd18a54809a25e63db389eacd3 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 9 Mar 2015 19:36:29 -0400 Subject: Update Security Unit test Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Security_test.php | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 7d415131b..8faf1b58a 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -45,7 +45,7 @@ class Security_test extends CI_TestCase { $this->assertInstanceOf('CI_Security', $this->security->csrf_verify()); } - + // -------------------------------------------------------------------- public function test_get_csrf_hash() @@ -70,7 +70,7 @@ class Security_test extends CI_TestCase { $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_string); } - + // -------------------------------------------------------------------- public function test_xss_clean_string_array() @@ -87,9 +87,9 @@ class Security_test extends CI_TestCase { $this->assertEquals("Simple clean string", $harmless_strings[1]); $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[2]); } - + // -------------------------------------------------------------------- - + public function test_xss_clean_image_valid() { $harm_string = ''; @@ -98,9 +98,9 @@ class Security_test extends CI_TestCase { $this->assertTrue($xss_clean_return); } - + // -------------------------------------------------------------------- - + public function test_xss_clean_image_invalid() { $harm_string = ''; @@ -109,31 +109,31 @@ class Security_test extends CI_TestCase { $this->assertFalse($xss_clean_return); } - + // -------------------------------------------------------------------- - + public function test_xss_clean_entity_double_encoded() { $input = 'Clickhere'; $this->assertEquals('Clickhere', $this->security->xss_clean($input)); } - + // -------------------------------------------------------------------- - + public function test_xss_clean_js_img_removal() { $input = 'Clickhere'; $this->assertEquals('', $this->security->xss_clean($input)); } - + // -------------------------------------------------------------------- - + public function test_xss_clean_sanitize_naughty_html() { $input = ''; $this->assertEquals('<blink>', $this->security->xss_clean($input)); } - + // -------------------------------------------------------------------- public function test_remove_evil_attributes() @@ -159,7 +159,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_get_random_bytes() { $length = "invalid"; @@ -169,7 +169,7 @@ class Security_test extends CI_TestCase { $length = 10; $this->assertNotEmpty($this->security->get_random_bytes($length)); } - + // -------------------------------------------------------------------- public function test_entity_decode() @@ -195,7 +195,7 @@ class Security_test extends CI_TestCase { $this->assertEquals('foo', $safe_filename); } - + // -------------------------------------------------------------------- public function test_strip_image_tags() @@ -227,9 +227,9 @@ class Security_test extends CI_TestCase { $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); } } - + // -------------------------------------------------------------------- - + public function test_csrf_set_hash() { // Set cookie for security test -- cgit v1.2.3-24-g4f1b From a1525136a25404c40dff8383ec7ff1b4f5d3e68b Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Tue, 10 Mar 2015 09:26:39 -0400 Subject: Fixed indentation Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Security_test.php | 131 +++++++++++++++---------------- 1 file changed, 65 insertions(+), 66 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 8faf1b58a..7f467fb1b 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -73,44 +73,44 @@ class Security_test extends CI_TestCase { // -------------------------------------------------------------------- - public function test_xss_clean_string_array() + public function test_xss_clean_string_array() { - $harm_strings = array( - "Hello, i try to your site", - "Simple clean string", - "Hello, i try to your site" - ); + $harm_strings = array( + "Hello, i try to your site", + "Simple clean string", + "Hello, i try to your site" + ); $harmless_strings = $this->security->xss_clean($harm_strings); - - $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[0]); - $this->assertEquals("Simple clean string", $harmless_strings[1]); - $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[2]); + + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[0]); + $this->assertEquals("Simple clean string", $harmless_strings[1]); + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_strings[2]); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- - public function test_xss_clean_image_valid() + public function test_xss_clean_image_valid() { - $harm_string = ''; + $harm_string = ''; $xss_clean_return = $this->security->xss_clean($harm_string, TRUE); $this->assertTrue($xss_clean_return); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- - public function test_xss_clean_image_invalid() + public function test_xss_clean_image_invalid() { - $harm_string = ''; + $harm_string = ''; $xss_clean_return = $this->security->xss_clean($harm_string, TRUE); $this->assertFalse($xss_clean_return); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- public function test_xss_clean_entity_double_encoded() { @@ -118,17 +118,17 @@ class Security_test extends CI_TestCase { $this->assertEquals('Clickhere', $this->security->xss_clean($input)); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- - public function test_xss_clean_js_img_removal() + public function test_xss_clean_js_img_removal() { $input = 'Clickhere'; $this->assertEquals('', $this->security->xss_clean($input)); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- - public function test_xss_clean_sanitize_naughty_html() + public function test_xss_clean_sanitize_naughty_html() { $input = ''; $this->assertEquals('<blink>', $this->security->xss_clean($input)); @@ -158,19 +158,18 @@ class Security_test extends CI_TestCase { $this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1); } - // -------------------------------------------------------------------- - - public function test_get_random_bytes() - { - $length = "invalid"; - $this->assertFalse($this->security->get_random_bytes($length)); + // -------------------------------------------------------------------- + public function test_get_random_bytes() + { + $length = "invalid"; + $this->assertFalse($this->security->get_random_bytes($length)); - $length = 10; - $this->assertNotEmpty($this->security->get_random_bytes($length)); - } + $length = 10; + $this->assertNotEmpty($this->security->get_random_bytes($length)); + } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- public function test_entity_decode() { @@ -196,54 +195,54 @@ class Security_test extends CI_TestCase { $this->assertEquals('foo', $safe_filename); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- public function test_strip_image_tags() { - $imgtags = Array( - 'Smiley face', - 'Smiley face', - '', - '', - 'MD Logo', - '', - '', - '' - ); - - $urls = Array( - 'smiley.gif', - 'smiley.gif', - 'http://www.w3schools.com/images/w3schools_green.jpg', - '/img/sunset.gif', - 'mdn-logo-sm.png', - '', - '', - '' - ); - - for($i = 0; $i < count($imgtags); $i++) - { - $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); - } + $imgtags = Array( + 'Smiley face', + 'Smiley face', + '', + '', + 'MD Logo', + '', + '', + '' + ); + + $urls = Array( + 'smiley.gif', + 'smiley.gif', + 'http://www.w3schools.com/images/w3schools_green.jpg', + '/img/sunset.gif', + 'mdn-logo-sm.png', + '', + '', + '' + ); + + for($i = 0; $i < count($imgtags); $i++) + { + $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); + } } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- - public function test_csrf_set_hash() + public function test_csrf_set_hash() { - // Set cookie for security test + // Set cookie for security test $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE)); // Set config for Security class $this->ci_set_config('csrf_protection', TRUE); $this->ci_set_config('csrf_token_name', 'ci_csrf_token'); - - // leave csrf_cookie_name as blank to test _csrf_set_hash function + + // leave csrf_cookie_name as blank to test _csrf_set_hash function $this->ci_set_config('csrf_cookie_name', ''); $this->security = new Mock_Core_Security(); - - $this->assertNotEmpty($this->security->get_csrf_hash()); - } + + $this->assertNotEmpty($this->security->get_csrf_hash()); + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 33992f542185a34c789d85d7709e7f812803a686 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 16 Mar 2015 20:17:59 -0400 Subject: Updated fetch_from_array unit test Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Input_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 21ff6d81f..d3f5a9048 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -134,6 +134,15 @@ class Input_test extends CI_TestCase { $this->assertEquals('bar', $foo); $this->assertEquals("Hello, i try to your site", $harm); $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless); + + $_SERVER['REQUEST_METHOD'] = 'POST'; + $_POST['foo']['bar'] = 'baz'; + $barArray = array( 'bar' => 'baz' ); + + $this->assertEquals('baz', $this->input->post('foo[bar]')); + $this->assertEquals($barArray, $this->input->post('foo[]')); + $this->assertNull($this->input->post('foo[baz]')); + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fe5099a695c25e503a0aff6124644b9011a27e0d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 18 Mar 2015 12:35:47 +0200 Subject: Polish some recent changes in test cases --- tests/codeigniter/core/Input_test.php | 10 ++++------ tests/codeigniter/core/Security_test.php | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index d3f5a9048..159a877dc 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -134,15 +134,14 @@ class Input_test extends CI_TestCase { $this->assertEquals('bar', $foo); $this->assertEquals("Hello, i try to your site", $harm); $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless); - + $_SERVER['REQUEST_METHOD'] = 'POST'; $_POST['foo']['bar'] = 'baz'; - $barArray = array( 'bar' => 'baz' ); - + $barArray = array('bar' => 'baz'); + $this->assertEquals('baz', $this->input->post('foo[bar]')); $this->assertEquals($barArray, $this->input->post('foo[]')); $this->assertNull($this->input->post('foo[baz]')); - } // -------------------------------------------------------------------- @@ -222,5 +221,4 @@ class Input_test extends CI_TestCase { // Back to reality $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality } - -} \ No newline at end of file +} diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 7f467fb1b..b5524da0f 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -138,12 +138,12 @@ class Security_test extends CI_TestCase { public function test_remove_evil_attributes() { - $this->assertEquals('', $this->security->remove_evil_attributes('', false)); - $this->assertEquals('', $this->security->remove_evil_attributes('', false)); - $this->assertEquals('', $this->security->remove_evil_attributes('', false)); - $this->assertEquals('', $this->security->remove_evil_attributes('', false)); - $this->assertEquals('onOutsideOfTag=test', $this->security->remove_evil_attributes('onOutsideOfTag=test', false)); - $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', false)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); + $this->assertEquals('onOutsideOfTag=test', $this->security->remove_evil_attributes('onOutsideOfTag=test', FALSE)); + $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', FALSE)); } // -------------------------------------------------------------------- @@ -199,7 +199,7 @@ class Security_test extends CI_TestCase { public function test_strip_image_tags() { - $imgtags = Array( + $imgtags = array( 'Smiley face', 'Smiley face', '', @@ -210,7 +210,7 @@ class Security_test extends CI_TestCase { '' ); - $urls = Array( + $urls = array( 'smiley.gif', 'smiley.gif', 'http://www.w3schools.com/images/w3schools_green.jpg', @@ -221,7 +221,7 @@ class Security_test extends CI_TestCase { '' ); - for($i = 0; $i < count($imgtags); $i++) + for ($i = 0; $i < count($imgtags); $i++) { $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i])); } @@ -245,4 +245,4 @@ class Security_test extends CI_TestCase { $this->assertNotEmpty($this->security->get_csrf_hash()); } -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b From 0fc46caedd690b05141a0b80bc5d7bca9b72b61b Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Wed, 18 Mar 2015 18:49:22 -0400 Subject: Updated CI_Input unit test and fixed error "undefined offset" caused by using the same variable name, $i, twice for for loop inside for loop. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Input_test.php | 61 ++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 159a877dc..a632ee689 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -206,9 +206,23 @@ class Input_test extends CI_TestCase { $this->markTestSkipped('TODO: Find a way to test HTTP headers'); } - public function test_ip_address() + // -------------------------------------------------------------------- + + public function test_get_request_header() { + //TODO: Find a way to test HTTP headers + $this->assertNull($this->input->get_request_header('test')); + } + + // -------------------------------------------------------------------- + + public function test_ip_address() + { + $this->input->ip_address = TRUE; + $this->assertTrue($this->input->ip_address()); + // 127.0.0.1 is set in our Bootstrap file + $this->input->ip_address = FALSE; $this->assertEquals('127.0.0.1', $this->input->ip_address()); // Invalid @@ -216,9 +230,46 @@ class Input_test extends CI_TestCase { $this->input->ip_address = FALSE; // reset cached value $this->assertEquals('0.0.0.0', $this->input->ip_address()); - // TODO: Add proxy_ips tests - - // Back to reality + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + + // Proxy_ips tests + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', '127.0.0.3, 127.0.0.4, 127.0.0.2'); + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; + $this->assertEquals('127.0.0.1', $this->input->ip_address()); + + // Invalid spoof + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', 'invalid_ip_address'); + $_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address'; + $this->assertEquals('127.0.0.1', $this->input->ip_address()); + + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1'); + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1'; + $this->assertEquals('127.0.0.1', $this->input->ip_address()); + + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1'); + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; + $this->assertNotEquals('127.0.0.1', $this->input->ip_address()); + + //IPv6 + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329/1, FE80:0000:0000:0000:0202:B3FF:FE1E:8300/2'); + $_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300'; + $_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'; + $this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address()); + + $this->input->ip_address = FALSE; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality } -} + + // -------------------------------------------------------------------- + + public function test_user_agent() + { + $_SERVER['HTTP_USER_AGENT'] = 'test'; + $this->assertEquals('test', $this->input->user_agent()); + } +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From c44a656649ca4d198f29ea1f07fe0174ce832ccc Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Wed, 18 Mar 2015 19:12:27 -0400 Subject: minor update Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Input_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index a632ee689..e269b1762 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -250,9 +250,10 @@ class Input_test extends CI_TestCase { $this->assertEquals('127.0.0.1', $this->input->ip_address()); $this->input->ip_address = FALSE; - $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1'); + $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.2'); $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; - $this->assertNotEquals('127.0.0.1', $this->input->ip_address()); + $_SERVER['REMOTE_ADDR'] = '127.0.0.2'; + $this->assertEquals('127.0.0.2', $this->input->ip_address()); //IPv6 $this->input->ip_address = FALSE; -- cgit v1.2.3-24-g4f1b From 78978b2a53692ebf8070d1cb96ad4c1609e12329 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Thu, 19 Mar 2015 10:32:36 -0400 Subject: updated based on comment Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Input_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index e269b1762..e6122cabc 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -210,8 +210,7 @@ class Input_test extends CI_TestCase { public function test_get_request_header() { - //TODO: Find a way to test HTTP headers - $this->assertNull($this->input->get_request_header('test')); + $this->markTestSkipped('TODO: Find a way to test HTTP headers'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 46a67d33388b4b79397f8f48ab39fcc2fdf8ea73 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Fri, 20 Mar 2015 09:22:01 -0400 Subject: updated based on comment Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Input_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index e6122cabc..d644d7fc7 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -217,8 +217,8 @@ class Input_test extends CI_TestCase { public function test_ip_address() { - $this->input->ip_address = TRUE; - $this->assertTrue($this->input->ip_address()); + $this->input->ip_address = '127.0.0.1'; + $this->assertEquals('127.0.0.1', $this->input->ip_address()); // 127.0.0.1 is set in our Bootstrap file $this->input->ip_address = FALSE; -- cgit v1.2.3-24-g4f1b From 94b758651f39cb3e3af335c71473102191965aeb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 21 Mar 2015 12:15:46 +0200 Subject: [ci skip] Whitespace cleanup following PR #3682 --- tests/codeigniter/core/Input_test.php | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index d644d7fc7..c56900d22 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -207,19 +207,19 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_get_request_header() { $this->markTestSkipped('TODO: Find a way to test HTTP headers'); } - + // -------------------------------------------------------------------- - + public function test_ip_address() - { + { $this->input->ip_address = '127.0.0.1'; $this->assertEquals('127.0.0.1', $this->input->ip_address()); - + // 127.0.0.1 is set in our Bootstrap file $this->input->ip_address = FALSE; $this->assertEquals('127.0.0.1', $this->input->ip_address()); @@ -230,46 +230,46 @@ class Input_test extends CI_TestCase { $this->assertEquals('0.0.0.0', $this->input->ip_address()); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - + // Proxy_ips tests $this->input->ip_address = FALSE; $this->ci_set_config('proxy_ips', '127.0.0.3, 127.0.0.4, 127.0.0.2'); - $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; $this->assertEquals('127.0.0.1', $this->input->ip_address()); - + // Invalid spoof $this->input->ip_address = FALSE; $this->ci_set_config('proxy_ips', 'invalid_ip_address'); - $_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address'; - $this->assertEquals('127.0.0.1', $this->input->ip_address()); - + $_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address'; + $this->assertEquals('127.0.0.1', $this->input->ip_address()); + $this->input->ip_address = FALSE; $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1'); - $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1'; + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1'; $this->assertEquals('127.0.0.1', $this->input->ip_address()); - + $this->input->ip_address = FALSE; $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.2'); - $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2'; $_SERVER['REMOTE_ADDR'] = '127.0.0.2'; $this->assertEquals('127.0.0.2', $this->input->ip_address()); - + //IPv6 $this->input->ip_address = FALSE; $this->ci_set_config('proxy_ips', 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329/1, FE80:0000:0000:0000:0202:B3FF:FE1E:8300/2'); - $_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300'; + $_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300'; $_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'; $this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address()); - + $this->input->ip_address = FALSE; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality } - + // -------------------------------------------------------------------- - + public function test_user_agent() { $_SERVER['HTTP_USER_AGENT'] = 'test'; $this->assertEquals('test', $this->input->user_agent()); } -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b From aebd039a61cb5135b31ab0b8d9d95ed3fb678c7b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Mar 2015 14:15:34 +0200 Subject: Add FSCommand and seekSegmentTime to evil HTML attributes list --- tests/codeigniter/core/Security_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index b5524da0f..3acd2a598 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -144,6 +144,8 @@ class Security_test extends CI_TestCase { $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); $this->assertEquals('onOutsideOfTag=test', $this->security->remove_evil_attributes('onOutsideOfTag=test', FALSE)); $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', FALSE)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); + $this->assertEquals('', $this->security->remove_evil_attributes('', FALSE)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 03404890a5a0ea9c5e02c235a94312741bdf05b2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Mar 2015 20:58:19 +0200 Subject: Remove an unnecessary check #3700 #3706 --- tests/codeigniter/core/Lang_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 87a71c885..929bc2ffd 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -32,7 +32,7 @@ class Lang_test extends CI_TestCase { // A language other than english $this->ci_vfs_clone('system/language/english/email_lang.php', 'system/language/german/'); $this->assertTrue($this->lang->load('email', 'german')); - $this->assertEquals('german', $this->lang->is_loaded['email_lang.php'] ); + $this->assertEquals('german', $this->lang->is_loaded['email_lang.php']); // Non-alpha idiom (should act the same as unspecified language) $this->ci_vfs_clone('system/language/english/number_lang.php'); @@ -60,5 +60,4 @@ class Lang_test extends CI_TestCase { $this->assertFalse($this->lang->line('nonexistent_string')); $this->assertFalse($this->lang->line(NULL)); } - } -- cgit v1.2.3-24-g4f1b From cbc21b9bdbaeb2defd47c0808d47801ab1a14ede Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 13:59:16 -0400 Subject: Increased code coverage Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 929bc2ffd..3c1e19db3 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', @@ -46,7 +46,30 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } + + // -------------------------------------------------------------------- + + public function test_multiple_file_load() + { + // Multiple files + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $files = Array('profiler', 'nonexistent'); + $this->setExpectedException( + 'RuntimeException', + 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' + ); + $this->assertTrue($this->lang->load($files, 'english')); + } + // -------------------------------------------------------------------- + + public function test_alternative_path_load() + { + // Alternative Path + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 4924115bdf8042850e7934d0ab66fe451e7c778b Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 15:10:16 -0400 Subject: removed space Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3c1e19db3..a4db7a9c2 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 7df6771e33c43b86a9e0bb8beb9d55aafec3b978 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 16:27:06 -0400 Subject: Improved unit test code coverage. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9e2092e05..64632c056 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -22,6 +22,9 @@ class Loader_test extends CI_TestCase { public function test_library() { + // Test getting CI_Loader object + $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -34,6 +37,13 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); + + // Create library in VFS + $lib = Array('unit_test_lib'=>'unit_test_lib'); + + // Test loading as an array (int). + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); + $this->assertTrue(class_exists($class), $class.' does not exist'); // Test a string given to params $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' ')); @@ -316,6 +326,24 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } + + // -------------------------------------------------------------------- + + public function test_clear_vars() + { + $key1 = 'foo'; + $val1 = 'bar'; + $key2 = 'boo'; + $val2 = 'hoo'; + $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1))); + $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); + $this->assertEquals($val1, $this->load->get_var($key1)); + $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); + + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); + $this->assertEquals('', $this->load->get_var($key1)); + $this->assertEquals('', $this->load->get_var($key2)); + } // -------------------------------------------------------------------- @@ -443,6 +471,24 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_remove_package_path() + { + $dir = 'third-party'; + $path = APPPATH.$dir.'/'; + $path2 = APPPATH.'another/'; + $paths = $this->load->get_package_paths(TRUE); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); + $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); + $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); + } + + // -------------------------------------------------------------------- + public function test_load_config() { $cfg = 'someconfig'; -- cgit v1.2.3-24-g4f1b From aa11370ba3d326eef259fedd5a67481b3aa95df6 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:05:47 -0400 Subject: added spaces Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 64632c056..6028521d1 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib'=>'unit_test_lib'); + $lib = Array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From d1f39fdef53fc510a6a5d19ec2991e5bc474bc29 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:11:32 -0400 Subject: updated array style and removed assert true Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index a4db7a9c2..3fccf096d 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,12 +53,15 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array('profiler', 'nonexistent'); + $files = Array( + 0 => 'profiler', + 1 => 'nonexistent' + ); $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' ); - $this->assertTrue($this->lang->load($files, 'english')); + $this->lang->load($files, 'english'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fc67a701a574641b5dfd7afe00d4c5d403111626 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:08:11 -0400 Subject: changed to lowercase array and space. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3fccf096d..0f6ffd3fa 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,9 +53,9 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array( - 0 => 'profiler', - 1 => 'nonexistent' + $files = array( + 0 => 'profiler', + 1 => 'nonexistent' ); $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 90e07bdaa034d98e23378c51105a8aea85878d07 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:10:00 -0400 Subject: changed to lowercase array. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 6028521d1..5e64b62b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib' => 'unit_test_lib'); + $lib = array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From 928134324d75ed4a876237ec00d4374b2213586a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 19:27:06 +0300 Subject: [ci skip] Whitespace cleanup following PRs #3713 #3714 --- tests/codeigniter/core/Lang_test.php | 12 ++++++------ tests/codeigniter/core/Loader_test.php | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 0f6ffd3fa..d2dd7598a 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -46,15 +46,15 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } - + // -------------------------------------------------------------------- - + public function test_multiple_file_load() - { + { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); $files = array( - 0 => 'profiler', + 0 => 'profiler', 1 => 'nonexistent' ); $this->setExpectedException( @@ -65,14 +65,14 @@ class Lang_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_alternative_path_load() { // Alternative Path $this->ci_vfs_clone('system/language/english/profiler_lang.php'); $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); } - + // -------------------------------------------------------------------- /** diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 5e64b62b9..cfaf6c74b 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -24,7 +24,7 @@ class Loader_test extends CI_TestCase { { // Test getting CI_Loader object $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); - + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -37,10 +37,10 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); - + // Create library in VFS $lib = array('unit_test_lib' => 'unit_test_lib'); - + // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertTrue(class_exists($class), $class.' does not exist'); @@ -326,7 +326,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } - + // -------------------------------------------------------------------- public function test_clear_vars() @@ -339,7 +339,7 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); - + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); $this->assertEquals('', $this->load->get_var($key1)); $this->assertEquals('', $this->load->get_var($key2)); @@ -477,18 +477,18 @@ class Loader_test extends CI_TestCase { $path = APPPATH.$dir.'/'; $path2 = APPPATH.'another/'; $paths = $this->load->get_package_paths(TRUE); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); } // -------------------------------------------------------------------- - + public function test_load_config() { $cfg = 'someconfig'; @@ -557,5 +557,4 @@ class Loader_test extends CI_TestCase { // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); } - -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b