|
23 | 23 |
|
24 | 24 | class HeadersContextCookieTest extends TestCase
|
25 | 25 | {
|
26 |
| - public static function cookieData(): iterable |
27 |
| - { |
28 |
| - return [ |
29 |
| - ['myCookie=; Path=/; Expires=Thursday, 01-Jan-1970 00:00:00 UTC; MaxAge=-1525132800', [ |
30 |
| - 'name' => 'myCookie', |
31 |
| - 'value' => null |
32 |
| - ]], |
33 |
| - ['fullCookie=foo; Domain=example.com; Path=/directory/; Expires=Tuesday, 01-May-2018 01:00:00 UTC; MaxAge=3600; Secure; HttpOnly; SameSite=Lax', [ |
34 |
| - 'name' => 'fullCookie', |
35 |
| - 'value' => 'foo', |
36 |
| - 'Secure' => true, |
37 |
| - 'MaxAge' => 3600, |
38 |
| - 'HttpOnly' => true, |
39 |
| - 'Domain' => 'example.com', |
40 |
| - 'Path' => '/directory/', |
41 |
| - 'SameSite' => 'Lax' |
42 |
| - ]], |
43 |
| - ['fullCookie=foo; Domain=example.com; Path=/directory/; Expires=Tuesday, 01-May-2018 01:00:00 UTC; MaxAge=3600; Secure; HttpOnly; SameSite=Lax', [ |
44 |
| - 'name' => 'fullCookie', |
45 |
| - 'value' => 'foo', |
46 |
| - 'Secure' => true, |
47 |
| - 'Expires' => FixedDateTime::withOffset(3600), |
48 |
| - 'HttpOnly' => true, |
49 |
| - 'Domain' => 'example.com', |
50 |
| - 'Path' => '/directory/', |
51 |
| - 'SameSite' => 'Lax' |
52 |
| - ]] |
53 |
| - ]; |
54 |
| - } |
55 |
| - |
56 |
| - public static function invalidNames(): iterable |
57 |
| - { |
58 |
| - return [['foo=bar'], ['żółty'], ['foo{bar}']]; |
59 |
| - } |
60 |
| - |
61 |
| - public static function invalidValues(): iterable |
62 |
| - { |
63 |
| - return [['foo\bar'], ['żółty'], ['foo;bar']]; |
64 |
| - } |
65 |
| - |
66 | 26 | public function test_Instantiation()
|
67 | 27 | {
|
68 | 28 | $this->assertInstanceOf(CookieSetup::class, $setup = $this->cookieSetup());
|
@@ -188,6 +148,46 @@ public function test_GivenCookieWasSent_SendCookie_ThrowsException()
|
188 | 148 | $cookie->send('value');
|
189 | 149 | }
|
190 | 150 |
|
| 151 | + public static function cookieData(): iterable |
| 152 | + { |
| 153 | + return [ |
| 154 | + ['myCookie=; Path=/; Expires=Thursday, 01-Jan-1970 00:00:00 UTC; MaxAge=-1525132800', [ |
| 155 | + 'name' => 'myCookie', |
| 156 | + 'value' => null |
| 157 | + ]], |
| 158 | + ['fullCookie=foo; Domain=example.com; Path=/directory/; Expires=Tuesday, 01-May-2018 01:00:00 UTC; MaxAge=3600; Secure; HttpOnly; SameSite=Lax', [ |
| 159 | + 'name' => 'fullCookie', |
| 160 | + 'value' => 'foo', |
| 161 | + 'Secure' => true, |
| 162 | + 'MaxAge' => 3600, |
| 163 | + 'HttpOnly' => true, |
| 164 | + 'Domain' => 'example.com', |
| 165 | + 'Path' => '/directory/', |
| 166 | + 'SameSite' => 'Lax' |
| 167 | + ]], |
| 168 | + ['fullCookie=foo; Domain=example.com; Path=/directory/; Expires=Tuesday, 01-May-2018 01:00:00 UTC; MaxAge=3600; Secure; HttpOnly; SameSite=Lax', [ |
| 169 | + 'name' => 'fullCookie', |
| 170 | + 'value' => 'foo', |
| 171 | + 'Secure' => true, |
| 172 | + 'Expires' => FixedDateTime::withOffset(3600), |
| 173 | + 'HttpOnly' => true, |
| 174 | + 'Domain' => 'example.com', |
| 175 | + 'Path' => '/directory/', |
| 176 | + 'SameSite' => 'Lax' |
| 177 | + ]] |
| 178 | + ]; |
| 179 | + } |
| 180 | + |
| 181 | + public static function invalidNames(): iterable |
| 182 | + { |
| 183 | + return [['foo=bar'], ['żółty'], ['foo{bar}']]; |
| 184 | + } |
| 185 | + |
| 186 | + public static function invalidValues(): iterable |
| 187 | + { |
| 188 | + return [['foo\bar'], ['żółty'], ['foo;bar']]; |
| 189 | + } |
| 190 | + |
191 | 191 | private function cookieSetup(?ResponseHeaders &$context = null): CookieSetup
|
192 | 192 | {
|
193 | 193 | return new CookieSetup($context ??= new ResponseHeaders());
|
|
0 commit comments