From 60108a735fa7c9af4ab0b71e74b226d4b554e32f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 16 Oct 2012 17:35:54 +0100 Subject: Cookie helper testsuite --- tests/codeigniter/helpers/cookie_helper_test.php | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/codeigniter/helpers/cookie_helper_test.php (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/cookie_helper_test.php b/tests/codeigniter/helpers/cookie_helper_test.php new file mode 100644 index 000000000..3c7c9fd2e --- /dev/null +++ b/tests/codeigniter/helpers/cookie_helper_test.php @@ -0,0 +1,59 @@ +helper('cookie'); + } + + // ------------------------------------------------------------------------ + + function test_set_cookie() + { + /*$input_cls = $this->ci_core_class('input'); + $this->ci_instance_var('input', new $input_cls); + + $this->assertTrue(set_cookie( + 'my_cookie', + 'foobar' + ));*/ + + $this->markTestIncomplete('Need to find a way to overcome a headers already set exception'); + } + + // ------------------------------------------------------------------------ + + function test_get_cookie() + { + $_COOKIE['foo'] = 'bar'; + + $security = new Mock_Core_Security(); + $utf8 = new Mock_Core_Utf8(); + $input_cls = $this->ci_core_class('input'); + $this->ci_instance_var('input', new Mock_Core_Input($security, $utf8)); + + $this->assertEquals('bar', get_cookie('foo', FALSE)); + $this->assertEquals('bar', get_cookie('foo', TRUE)); + + $_COOKIE['bar'] = "Hello, i try to your site"; + + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", get_cookie('bar', TRUE)); + $this->assertEquals("Hello, i try to your site", get_cookie('bar', FALSE)); + } + + // ------------------------------------------------------------------------ + + function test_delete_cookie() + { + /*$input_cls = $this->ci_core_class('input'); + $this->ci_instance_var('input', new $input_cls); + + $this->assertTrue(delete_cookie( + 'my_cookie' + ));*/ + + $this->markTestIncomplete('Need to find a way to overcome a headers already set exception'); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a0f99d8930f175b7869ccaca834b3437b1a7b4ef Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 16 Oct 2012 18:18:54 +0100 Subject: Added captcha helper test Note, test isn't implemented Signed-off-by: Alex Bilbie --- tests/codeigniter/helpers/captcha_helper_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/codeigniter/helpers/captcha_helper_test.php (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php new file mode 100644 index 000000000..4fbda2a88f --- /dev/null +++ b/tests/codeigniter/helpers/captcha_helper_test.php @@ -0,0 +1,10 @@ +markTestIncomplete(); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 1624b4297c89334362f6ade5f5b766c916ffcbb1 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 16 Oct 2012 18:19:06 +0100 Subject: Added download helper test Note, test isn't implemented Signed-off-by: Alex Bilbie --- tests/codeigniter/helpers/download_helper_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/codeigniter/helpers/download_helper_test.php (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/download_helper_test.php b/tests/codeigniter/helpers/download_helper_test.php new file mode 100644 index 000000000..b41a8532a --- /dev/null +++ b/tests/codeigniter/helpers/download_helper_test.php @@ -0,0 +1,10 @@ +markTestIncomplete(); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 526d88f7d1d91bd51b3aa27ee8e170b7fa39a639 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 16 Oct 2012 18:19:30 +0100 Subject: Added language helper unit test Signed-off-by: Alex Bilbie --- tests/codeigniter/helpers/language_helper_test.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/codeigniter/helpers/language_helper_test.php (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/language_helper_test.php b/tests/codeigniter/helpers/language_helper_test.php new file mode 100644 index 000000000..06932b9fd --- /dev/null +++ b/tests/codeigniter/helpers/language_helper_test.php @@ -0,0 +1,14 @@ +helper('language'); + $this->ci_instance_var('lang', new Mock_Core_Lang()); + + $this->assertFalse(lang(1)); + $this->assertEquals('', lang(1, 'foo')); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0f5b3060ff04b064b1a4bee9b114357ccd5a57de Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 16 Oct 2012 18:19:40 +0100 Subject: Added security helper unit test Signed-off-by: Alex Bilbie --- tests/codeigniter/helpers/security_helper_test.php | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/codeigniter/helpers/security_helper_test.php (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/security_helper_test.php b/tests/codeigniter/helpers/security_helper_test.php new file mode 100644 index 000000000..effd3ec02 --- /dev/null +++ b/tests/codeigniter/helpers/security_helper_test.php @@ -0,0 +1,64 @@ +helper('security'); + $obj = new stdClass; + $obj->security = new Mock_Core_Security(); + $this->ci_instance($obj); + } + + function test_xss_clean() + { + $this->assertEquals('foo', xss_clean('foo')); + + $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", xss_clean("Hello, i try to your site")); + } + + function test_sanitize_filename() + { + $this->assertEquals('hello.doc', sanitize_filename('hello.doc')); + + $filename = './'; + $this->assertEquals('foo', sanitize_filename($filename)); + } + + function test_do_hash() + { + $md5 = md5('foo'); + $sha1 = sha1('foo'); + + $algos = hash_algos(); + $algo_results = array(); + foreach ($algos as $k => $v) + { + $algo_results[$v] = hash($v, 'foo'); + } + + $this->assertEquals($sha1, do_hash('foo')); + $this->assertEquals($sha1, do_hash('foo', 'sha1')); + $this->assertEquals($md5, do_hash('foo', 'md5')); + $this->assertEquals($md5, do_hash('foo', 'foobar')); + + // Test each algorithm available to PHP + foreach ($algo_results as $algo => $result) + { + $this->assertEquals($result, do_hash('foo', $algo)); + } + } + + function test_strip_image_tags() + { + $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('http://example.com/spacer.gif')); + + $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('Who needs CSS when you have a spacer.gif?')); + } + + function test_encode_php_tags() + { + $this->assertEquals('<? echo $foo; ?>', encode_php_tags('')); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4b3cf8d825e13d4f24654fc6b26f2ca15d73c4f8 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Thu, 18 Oct 2012 16:44:54 +0100 Subject: Marked tests that can't easily be tests as skipped Signed-off-by: Alex Bilbie --- tests/codeigniter/helpers/captcha_helper_test.php | 2 +- tests/codeigniter/helpers/cookie_helper_test.php | 4 ++-- tests/codeigniter/helpers/download_helper_test.php | 2 +- tests/codeigniter/libraries/Upload_test.php | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php index 4fbda2a88f..fc86305e3 100644 --- a/tests/codeigniter/helpers/captcha_helper_test.php +++ b/tests/codeigniter/helpers/captcha_helper_test.php @@ -4,7 +4,7 @@ class Captcha_helper_test extends CI_TestCase { public function test_create_captcha() { - $this->markTestIncomplete(); + $this->markTestSkipped('Cant easily test'); } } \ No newline at end of file diff --git a/tests/codeigniter/helpers/cookie_helper_test.php b/tests/codeigniter/helpers/cookie_helper_test.php index 3c7c9fd2e..fba68f20f 100644 --- a/tests/codeigniter/helpers/cookie_helper_test.php +++ b/tests/codeigniter/helpers/cookie_helper_test.php @@ -19,7 +19,7 @@ class Cookie_helper_test extends CI_TestCase { 'foobar' ));*/ - $this->markTestIncomplete('Need to find a way to overcome a headers already set exception'); + $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); } // ------------------------------------------------------------------------ @@ -53,7 +53,7 @@ class Cookie_helper_test extends CI_TestCase { 'my_cookie' ));*/ - $this->markTestIncomplete('Need to find a way to overcome a headers already set exception'); + $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); } } \ No newline at end of file diff --git a/tests/codeigniter/helpers/download_helper_test.php b/tests/codeigniter/helpers/download_helper_test.php index b41a8532a..d2b42e46b 100644 --- a/tests/codeigniter/helpers/download_helper_test.php +++ b/tests/codeigniter/helpers/download_helper_test.php @@ -4,7 +4,7 @@ class Download_helper_test extends CI_TestCase { public function test_force_download() { - $this->markTestIncomplete(); + $this->markTestSkipped('Cant easily test'); } } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index d79a3ffc9..b4ef7bbd1 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -18,9 +18,9 @@ class Upload_test extends CI_TestCase { $this->_test_dir = vfsStreamWrapper::getRoot(); } - function test_do_upload() + function test_do_upload() { - $this->markTestIncomplete('We can\'t really test this at the moment because of the call to `is_uploaded_file` in do_upload which isn\'t supported by vfsStream'); + $this->markTestSkipped('We can\'t really test this at the moment because of the call to `is_uploaded_file` in do_upload which isn\'t supported by vfsStream'); } function test_data() @@ -75,7 +75,7 @@ class Upload_test extends CI_TestCase { { $this->upload->set_max_filesize(100); $this->assertEquals(100, $this->upload->max_size); - } + } function test_set_max_filename() { @@ -87,7 +87,7 @@ class Upload_test extends CI_TestCase { { $this->upload->set_max_width(100); $this->assertEquals(100, $this->upload->max_width); - } + } function test_set_max_height() { @@ -181,7 +181,7 @@ class Upload_test extends CI_TestCase { $this->upload->file_type = 'image/gif'; $this->upload->file_temp = 'tests/mocks/uploads/ci_logo.gif'; - $this->upload->max_width = 10; + $this->upload->max_width = 10; $this->assertFalse($this->upload->is_allowed_dimensions()); $this->upload->max_width = 170; -- cgit v1.2.3-24-g4f1b From 929e1241879c94bff85203d2e00623284d72dc87 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 19 Oct 2012 10:09:28 +0300 Subject: Manually apply an improved version of PR #1797 (auto_link() URL helper) --- tests/codeigniter/helpers/url_helper_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index c81c5f1b8..5fc364238 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -51,6 +51,8 @@ class Url_helper_test extends CI_TestCase { 'www.codeigniter.com test' => 'http://www.codeigniter.com test', 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test', '
www.google.com' => '
http://www.google.com', + 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at http://www.codeigniter.com. Period test.', + 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at http://www.codeigniter.com, comma test' ); foreach ($strings as $in => $out) -- cgit v1.2.3-24-g4f1b