File tree Expand file tree Collapse file tree 1 file changed +82
-0
lines changed
Filter options
tests/Symfony/Tests/Component/HttpFoundation Expand file tree Collapse file tree 1 file changed +82
-0
lines changed
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Tests \Component \HttpFoundation ;
13
+
14
+ use Symfony \Component \HttpFoundation \Cookie ;
15
+
16
+ /**
17
+ * CookieTest
18
+ *
19
+ * @author John Kary <john@johnkary.net>
20
+ */
21
+ class CookieTest extends \PHPUnit_Framework_TestCase
22
+ {
23
+ public function invalidNames ()
24
+ {
25
+ return array (
26
+ array ('' ),
27
+ array (",MyName " ),
28
+ array (";MyName " ),
29
+ array (" MyName " ),
30
+ array ("\tMyName " ),
31
+ array ("\rMyName " ),
32
+ array ("\nMyName " ),
33
+ array ("\013MyName " ),
34
+ array ("\014MyName " ),
35
+ );
36
+ }
37
+
38
+ public function invalidValues ()
39
+ {
40
+ return array (
41
+ array (",MyValue " ),
42
+ array (";MyValue " ),
43
+ array (" MyValue " ),
44
+ array ("\tMyValue " ),
45
+ array ("\rMyValue " ),
46
+ array ("\nMyValue " ),
47
+ array ("\013MyValue " ),
48
+ array ("\014MyValue " ),
49
+ );
50
+ }
51
+
52
+ /**
53
+ * @dataProvider invalidNames
54
+ * @expectedException InvalidArgumentException
55
+ * @covers Symfony\Component\HttpFoundation\Cookie::__construct
56
+ */
57
+ public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters ($ name )
58
+ {
59
+ new Cookie ($ name );
60
+ }
61
+
62
+ /**
63
+ * @dataProvider invalidValues
64
+ * @expectedException InvalidArgumentException
65
+ * @covers Symfony\Component\HttpFoundation\Cookie::__construct
66
+ */
67
+ public function testInstantiationThrowsExceptionIfCookieValueContainsInvalidCharacters ($ value )
68
+ {
69
+ new Cookie ('MyCookie ' , $ value );
70
+ }
71
+
72
+ /**
73
+ * @covers Symfony\Component\HttpFoundation\Cookie::getValue
74
+ */
75
+ public function testGetValue ()
76
+ {
77
+ $ value = 'MyValue ' ;
78
+ $ cookie = new Cookie ('MyCookie ' , $ value );
79
+
80
+ $ this ->assertSame ($ value , $ cookie ->getValue (), '->getValue() returns the proper value ' );
81
+ }
82
+ }
You can’t perform that action at this time.
0 commit comments