Skip to content

Commit 7e92bc4

Browse files
committed
test: add test
1 parent 7a30b75 commit 7e92bc4

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/system/HTTP/ResponseCookieTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter\HTTP;
1313

14+
use CodeIgniter\Config\Factories;
1415
use CodeIgniter\Cookie\Cookie;
1516
use CodeIgniter\Cookie\CookieStore;
1617
use CodeIgniter\Cookie\Exceptions\CookieException;
@@ -255,6 +256,7 @@ public function testCookieStrictSetSameSite()
255256

256257
public function testCookieBlankSetSameSite()
257258
{
259+
/** @var \Config\Cookie $config */
258260
$config = config('Cookie');
259261
$config->samesite = '';
260262
$response = new Response(new App());
@@ -314,6 +316,30 @@ public function testCookieInvalidSameSite()
314316
]);
315317
}
316318

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+
317343
public function testGetCookieStore()
318344
{
319345
$response = new Response(new App());

0 commit comments

Comments
 (0)