Skip to content

Commit a001fcd

Browse files
test with settings
1 parent 6f5ee01 commit a001fcd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/SameSiteCookieMiddlewareTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,29 @@ public function testDefaultConfiguration(): void
3232
$this->assertSame('PHPSESSID=v3absd19o9pi6cjvhb5pkmsfo9; path=/; Secure; HttpOnly; SameSite=Lax;', $cookie);
3333
$this->assertSame('', (string)$response->getBody());
3434
}
35+
36+
/**
37+
* Test with own settings.
38+
*/
39+
public function testDefaultConfigurationWithOwnSettings(): void
40+
{
41+
$settings = [
42+
'start_session' => true,
43+
'same_site' => 'Strict',
44+
'http_only' => false,
45+
];
46+
47+
$configuration = new SameSiteCookieConfiguration($settings);
48+
49+
session_id('v3absd19o9pi6cjvhb5pkmsfo9');
50+
51+
$response = $this->runQueue([
52+
new SameSiteSessionMiddleware(),
53+
new SameSiteCookieMiddleware($configuration),
54+
]);
55+
56+
$cookie = $response->getHeaderLine('Set-Cookie');
57+
$this->assertSame('PHPSESSID=v3absd19o9pi6cjvhb5pkmsfo9; path=/; Secure; SameSite=Strict;', $cookie);
58+
$this->assertSame('', (string)$response->getBody());
59+
}
3560
}

0 commit comments

Comments
 (0)