Merge pull request #1894 from GDmac/develop

Session Native, respect cookie settings
diff --git a/composer.json b/composer.json
index dc098ac..7d60020 100644
--- a/composer.json
+++ b/composer.json
@@ -3,6 +3,6 @@
         "mikey179/vfsStream": "*"
     },
     "require-dev": {
-		"EHER/PHPUnit": "*"
+		"phpunit/phpunit": "*"
 	}
 }
\ No newline at end of file
diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php
new file mode 100644
index 0000000..4fbda2a88f
--- /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->markTestIncomplete();
+	}
+
+}
\ 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 0000000..3c7c9fd
--- /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->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 <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->markTestIncomplete('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 0000000..b41a853
--- /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->markTestIncomplete();
+	}
+
+}
\ 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 0000000..06932b9
--- /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 0000000..effd3ec
--- /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