Alex Bilbie | 60108a7 | 2012-10-16 17:35:54 +0100 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class Cookie_helper_test extends CI_TestCase { |
| 4 | |
| 5 | public function set_up() |
| 6 | { |
| 7 | $this->helper('cookie'); |
| 8 | } |
| 9 | |
| 10 | // ------------------------------------------------------------------------ |
| 11 | |
| 12 | function test_set_cookie() |
| 13 | { |
| 14 | /*$input_cls = $this->ci_core_class('input'); |
| 15 | $this->ci_instance_var('input', new $input_cls); |
| 16 | |
| 17 | $this->assertTrue(set_cookie( |
| 18 | 'my_cookie', |
| 19 | 'foobar' |
| 20 | ));*/ |
| 21 | |
Alex Bilbie | 4b3cf8d | 2012-10-18 16:44:54 +0100 | [diff] [blame^] | 22 | $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); |
Alex Bilbie | 60108a7 | 2012-10-16 17:35:54 +0100 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | // ------------------------------------------------------------------------ |
| 26 | |
| 27 | function test_get_cookie() |
| 28 | { |
| 29 | $_COOKIE['foo'] = 'bar'; |
| 30 | |
| 31 | $security = new Mock_Core_Security(); |
| 32 | $utf8 = new Mock_Core_Utf8(); |
| 33 | $input_cls = $this->ci_core_class('input'); |
| 34 | $this->ci_instance_var('input', new Mock_Core_Input($security, $utf8)); |
| 35 | |
| 36 | $this->assertEquals('bar', get_cookie('foo', FALSE)); |
| 37 | $this->assertEquals('bar', get_cookie('foo', TRUE)); |
| 38 | |
| 39 | $_COOKIE['bar'] = "Hello, i try to <script>alert('Hack');</script> your site"; |
| 40 | |
| 41 | $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", get_cookie('bar', TRUE)); |
| 42 | $this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", get_cookie('bar', FALSE)); |
| 43 | } |
| 44 | |
| 45 | // ------------------------------------------------------------------------ |
| 46 | |
| 47 | function test_delete_cookie() |
| 48 | { |
| 49 | /*$input_cls = $this->ci_core_class('input'); |
| 50 | $this->ci_instance_var('input', new $input_cls); |
| 51 | |
| 52 | $this->assertTrue(delete_cookie( |
| 53 | 'my_cookie' |
| 54 | ));*/ |
| 55 | |
Alex Bilbie | 4b3cf8d | 2012-10-18 16:44:54 +0100 | [diff] [blame^] | 56 | $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); |
Alex Bilbie | 60108a7 | 2012-10-16 17:35:54 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } |