summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-22 15:56:51 +0200
committerAndrey Andreev <narf@bofh.bg>2012-10-22 15:56:51 +0200
commit273cc47ae496f74a482ab47b305537a3fa1925f7 (patch)
tree86843e04095b6e210ee6837fcf23f5d551ee3932 /tests/codeigniter
parentf83c4363b5459d294255e3817a230258861ec79b (diff)
parent3fb026713013b60845c4cfe633a8a59a30b9c7dd (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into feature/db_qb_aliasing
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/helpers/captcha_helper_test.php10
-rw-r--r--tests/codeigniter/helpers/cookie_helper_test.php59
-rw-r--r--tests/codeigniter/helpers/download_helper_test.php10
-rw-r--r--tests/codeigniter/helpers/language_helper_test.php14
-rw-r--r--tests/codeigniter/helpers/security_helper_test.php64
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php2
-rw-r--r--tests/codeigniter/libraries/Upload_test.php10
7 files changed, 164 insertions, 5 deletions
diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php
new file mode 100644
index 000000000..fc86305e3
--- /dev/null
+++ b/tests/codeigniter/helpers/captcha_helper_test.php
@@ -0,0 +1,10 @@
+<?php
+
+class Captcha_helper_test extends CI_TestCase {
+
+ public function test_create_captcha()
+ {
+ $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
new file mode 100644
index 000000000..fba68f20f
--- /dev/null
+++ b/tests/codeigniter/helpers/cookie_helper_test.php
@@ -0,0 +1,59 @@
+<?php
+
+class Cookie_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->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->markTestSkipped('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 <script>alert('Hack');</script> your site";
+
+ $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", get_cookie('bar', TRUE));
+ $this->assertEquals("Hello, i try to <script>alert('Hack');</script> 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->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
new file mode 100644
index 000000000..d2b42e46b
--- /dev/null
+++ b/tests/codeigniter/helpers/download_helper_test.php
@@ -0,0 +1,10 @@
+<?php
+
+class Download_helper_test extends CI_TestCase {
+
+ public function test_force_download()
+ {
+ $this->markTestSkipped('Cant easily test');
+ }
+
+} \ No newline at end of file
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 @@
+<?php
+
+class Language_helper_test extends CI_TestCase {
+
+ public function test_lang()
+ {
+ $this->helper('language');
+ $this->ci_instance_var('lang', new Mock_Core_Lang());
+
+ $this->assertFalse(lang(1));
+ $this->assertEquals('<label for="foo"></label>', lang(1, 'foo'));
+ }
+
+} \ No newline at end of file
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 @@
+<?php
+
+class Security_helper_tests extends CI_TestCase {
+
+ function setUp()
+ {
+ $this->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&#40;'Hack'&#41;;[removed] your site", xss_clean("Hello, i try to <script>alert('Hack');</script> your site"));
+ }
+
+ function test_sanitize_filename()
+ {
+ $this->assertEquals('hello.doc', sanitize_filename('hello.doc'));
+
+ $filename = './<!--foo-->';
+ $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('<img src="http://example.com/spacer.gif" alt="Who needs CSS when you have a spacer.gif?" />'));
+ }
+
+ function test_encode_php_tags()
+ {
+ $this->assertEquals('&lt;? echo $foo; ?&gt;', encode_php_tags('<? echo $foo; ?>'));
+ }
+
+} \ No newline at end of file
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' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test',
'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
'<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
+ 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>. Period test.',
+ 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>, comma test'
);
foreach ($strings as $in => $out)
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;