Skip to content

Commit

Permalink
Issue delight-im#35 Added test for Partitioned cookies. I found the t…
Browse files Browse the repository at this point in the history
…ests not working that well (PHP 8.3) however.
  • Loading branch information
phpguru committed Aug 7, 2024
1 parent dc929ad commit 54f7d47
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
// start output buffering
\ob_start();

\testCookie(null);
\testCookie(false);
\testCookie('');
\testCookie(0);
try {
\testCookie(null);
\testCookie(false);
\testCookie('');
\testCookie(0);
\testCookie('hello', null);
} catch (\Throwable $e) {
echo $e->getMessage();
}
\testCookie('hello');
\testCookie('hello', false);
\testCookie('hello', true);
\testCookie('hello', null);
\testCookie('hello', '');
\testCookie('hello', 0);
\testCookie('hello', 1);
Expand Down Expand Up @@ -118,6 +122,7 @@
\testEqual((new \Delight\Cookie\Cookie('key'))->setValue('value')->setDomain('.www.example.com'), 'Set-Cookie: key=value; path=/; domain=.www.example.com; httponly; SameSite=Lax');
\testEqual((new \Delight\Cookie\Cookie('key'))->setValue('value')->setDomain('blog.example.com'), 'Set-Cookie: key=value; path=/; domain=.blog.example.com; httponly; SameSite=Lax');
\testEqual((new \Delight\Cookie\Cookie('key'))->setValue('value')->setDomain('.blog.example.com'), 'Set-Cookie: key=value; path=/; domain=.blog.example.com; httponly; SameSite=Lax');
\testEqual((new \Delight\Cookie\Cookie('SID'))->setValue('31d4d96e407aad42')->setSameSiteRestriction('Lax')->setSecureOnly(true)->setPartitioned(true), 'Set-Cookie: SID=31d4d96e407aad42; path=/; secure; httponly; SameSite=Lax; Partitioned');

\testEqual(\Delight\Cookie\Cookie::parse('Set-Cookie: SID'), '');
\testEqual(\Delight\Cookie\Cookie::parse('Set-Cookie: SID=31d4d96e407aad42'), 'Set-Cookie: SID=31d4d96e407aad42');
Expand Down

0 comments on commit 54f7d47

Please sign in to comment.