Skip to content

Commit 2b7fb20

Browse files
committed
chore: CHIPS partitioned cookies tests
1 parent 4f879db commit 2b7fb20

File tree

2 files changed

+68
-23
lines changed

2 files changed

+68
-23
lines changed

tests/Dflydev/FigCookies/SetCookieTest.php

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,51 @@ public function provideParsesFromSetCookieStringData(): array
110110
[
111111
'lu=Rg3vHJZnehYLjVg7qi3bZjzg; Domain=.example.com; Path=/; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Max-Age=500; Secure; HttpOnly',
112112
SetCookie::create('lu')
113-
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
114-
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
115-
->withMaxAge(500)
116-
->withPath('/')
117-
->withDomain('.example.com')
118-
->withSecure(true)
119-
->withHttpOnly(true),
113+
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
114+
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
115+
->withMaxAge(500)
116+
->withPath('/')
117+
->withDomain('.example.com')
118+
->withSecure(true)
119+
->withHttpOnly(true),
120120
],
121121
[
122122
'lu=Rg3vHJZnehYLjVg7qi3bZjzg; Domain=.example.com; Path=/; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Max-Age=500; Secure; HttpOnly; SameSite=Strict',
123123
SetCookie::create('lu')
124-
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
125-
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
126-
->withMaxAge(500)
127-
->withPath('/')
128-
->withDomain('.example.com')
129-
->withSecure(true)
130-
->withHttpOnly(true)
131-
->withSameSite(SameSite::strict()),
124+
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
125+
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
126+
->withMaxAge(500)
127+
->withPath('/')
128+
->withDomain('.example.com')
129+
->withSecure(true)
130+
->withHttpOnly(true)
131+
->withSameSite(SameSite::strict()),
132132
],
133133
[
134134
'lu=Rg3vHJZnehYLjVg7qi3bZjzg; Domain=.example.com; Path=/; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Max-Age=500; Secure; HttpOnly; SameSite=Lax',
135135
SetCookie::create('lu')
136-
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
137-
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
138-
->withMaxAge(500)
139-
->withPath('/')
140-
->withDomain('.example.com')
141-
->withSecure(true)
142-
->withHttpOnly(true)
143-
->withSameSite(SameSite::lax()),
136+
->withValue('Rg3vHJZnehYLjVg7qi3bZjzg')
137+
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
138+
->withMaxAge(500)
139+
->withPath('/')
140+
->withDomain('.example.com')
141+
->withSecure(true)
142+
->withHttpOnly(true)
143+
->withSameSite(SameSite::lax()),
144144
],
145+
[
146+
'lu=d2ioU4.4KDUjjnCGNut4; Domain=.example.com; Path=/; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Max-Age=500; Secure; HttpOnly; SameSite=Lax; Partitioned',
147+
SetCookie::create('lu')
148+
->withValue('d2ioU4.4KDUjjnCGNut4')
149+
->withExpires(new DateTime('Tue, 15-Jan-2013 21:47:38 GMT'))
150+
->withMaxAge(500)
151+
->withPath('/')
152+
->withDomain('.example.com')
153+
->withSecure(true)
154+
->withHttpOnly(true)
155+
->withSameSite(SameSite::lax())
156+
->withPartitioned()
157+
]
145158
];
146159
}
147160

@@ -171,6 +184,24 @@ public function it_creates_long_living_cookies(): void
171184
self::assertGreaterThan($fourYearsFromNow, $setCookie->getExpires());
172185
}
173186

187+
/**
188+
* @test
189+
*/
190+
public function it_creates_partitioned_cookies(): void
191+
{
192+
$setCookie = SetCookie::create('chips_cookie')->withPartitioned();
193+
self::assertEquals(true, $setCookie->getPartitioned());
194+
}
195+
196+
/**
197+
* @test
198+
*/
199+
public function it_does_not_set_partitioned_cookies_by_default(): void
200+
{
201+
$setCookie = SetCookie::create('non_chips_cookie');
202+
self::assertEquals(false, $setCookie->getPartitioned());
203+
}
204+
174205
/** @test */
175206
public function SameSite_modifier_can_be_added_and_removed(): void
176207
{

tests/Dflydev/FigCookies/SetCookiesTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ public function provideSetCookieStringsAndExpectedSetCookiesData(): array
181181
SetCookie::create('c', 'CCC'),
182182
],
183183
],
184+
[
185+
[
186+
'd=DDD',
187+
'e=EEE; Partitioned',
188+
'f=FFF',
189+
'g=GGG; Partitioned',
190+
],
191+
[
192+
SetCookie::create('d', 'DDD'),
193+
SetCookie::create('e', 'EEE')->withPartitioned(),
194+
SetCookie::create('f', 'FFF'),
195+
SetCookie::create('g', 'GGG')->withPartitioned()
196+
]
197+
]
184198
];
185199
}
186200

0 commit comments

Comments
 (0)