|
11 | 11 |
|
12 | 12 | namespace CodeIgniter\HTTP; |
13 | 13 |
|
| 14 | +use CodeIgniter\Config\Factories; |
14 | 15 | use CodeIgniter\Cookie\Cookie; |
15 | 16 | use CodeIgniter\Cookie\CookieStore; |
16 | 17 | use CodeIgniter\Cookie\Exceptions\CookieException; |
@@ -255,6 +256,7 @@ public function testCookieStrictSetSameSite() |
255 | 256 |
|
256 | 257 | public function testCookieBlankSetSameSite() |
257 | 258 | { |
| 259 | + /** @var \Config\Cookie $config */ |
258 | 260 | $config = config('Cookie'); |
259 | 261 | $config->samesite = ''; |
260 | 262 | $response = new Response(new App()); |
@@ -314,6 +316,30 @@ public function testCookieInvalidSameSite() |
314 | 316 | ]); |
315 | 317 | } |
316 | 318 |
|
| 319 | + public function testSetCookieConfigCookieIsUsed() |
| 320 | + { |
| 321 | + /** @var \Config\Cookie $config */ |
| 322 | + $config = config('Cookie'); |
| 323 | + $config->secure = true; |
| 324 | + $config->httponly = true; |
| 325 | + $config->samesite = 'None'; |
| 326 | + Factories::injectMock('config', 'Cookie', $config); |
| 327 | + |
| 328 | + $cookieAttr = [ |
| 329 | + 'name' => 'bar', |
| 330 | + 'value' => 'foo', |
| 331 | + 'expire' => 9999, |
| 332 | + ]; |
| 333 | + $response = new Response(new App()); |
| 334 | + $response->setCookie($cookieAttr); |
| 335 | + |
| 336 | + $cookie = $response->getCookie('bar'); |
| 337 | + $options = $cookie->getOptions(); |
| 338 | + $this->assertTrue($options['secure']); |
| 339 | + $this->assertTrue($options['httponly']); |
| 340 | + $this->assertSame('None', $options['samesite']); |
| 341 | + } |
| 342 | + |
317 | 343 | public function testGetCookieStore() |
318 | 344 | { |
319 | 345 | $response = new Response(new App()); |
|
0 commit comments