blob: fba68f20fae19e794c2db52d1d0175643e85abee [file] [log] [blame]
Alex Bilbie60108a72012-10-16 17:35:54 +01001<?php
2
3class 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 Bilbie4b3cf8d2012-10-18 16:44:54 +010022 $this->markTestSkipped('Need to find a way to overcome a headers already set exception');
Alex Bilbie60108a72012-10-16 17:35:54 +010023 }
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&#40;'Hack'&#41;;[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 Bilbie4b3cf8d2012-10-18 16:44:54 +010056 $this->markTestSkipped('Need to find a way to overcome a headers already set exception');
Alex Bilbie60108a72012-10-16 17:35:54 +010057 }
58
59}