Skip to content

Commit cb66dda

Browse files
authored
Merge pull request #128 from littleredbutton/updated-set-cookie-test
Updated SetCookieTest to pull fix from Guzzle
2 parents 2a92906 + cdcfb98 commit cb66dda

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

tests/unit/Http/SetCookieTest.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ public function pathMatchProvider(): array
170170

171171
/**
172172
* @dataProvider pathMatchProvider
173-
*
174-
* @param string $cookiePath
175-
* @param string $requestPath
176-
* @param bool $isMatch
177173
*/
178174
public function testMatchesPath(string $cookiePath, string $requestPath, bool $isMatch): void
179175
{
@@ -199,9 +195,6 @@ public function cookieValidateProvider(): array
199195
/**
200196
* @dataProvider cookieValidateProvider
201197
*
202-
* @param string $name
203-
* @param string|null $value
204-
* @param string $domain
205198
* @param bool|string $result
206199
*/
207200
public function testValidatesCookies(string $name, ?string $value, string $domain, $result): void
@@ -401,26 +394,19 @@ public function cookieParserDataProvider(): array
401394
* @dataProvider cookieParserDataProvider
402395
*
403396
* @param string|array $cookie
404-
* @param array $parsed
405397
*/
406398
public function testParseCookie($cookie, array $parsed): void
407399
{
408-
if (\PHP_VERSION_ID >= 80000) {
409-
self::markTestSkipped('This test is possibly using incorrect code and is broken starting from PHP 8. ' .
410-
'See https://github.com/littleredbutton/bigbluebutton-api-php/pull/70#discussion_r637602067 and ' .
411-
'https://github.com/guzzle/guzzle/issues/2894 for details.');
412-
}
413-
414400
foreach ((array) $cookie as $v) {
415401
$c = SetCookie::fromString($v);
416402
$p = $c->toArray();
417403

418404
if (isset($p['Expires'])) {
419-
// Remove expires values from the assertion if they are relatively equal
420-
if (\abs($p['Expires'] != \strtotime((string) $parsed['Expires'])) < 40) {
421-
unset($p['Expires']);
422-
unset($parsed['Expires']);
423-
}
405+
$delta = 40;
406+
$parsedExpires = \is_numeric($parsed['Expires']) ? $parsed['Expires'] : \strtotime($parsed['Expires']);
407+
self::assertLessThan($delta, \abs($p['Expires'] - $parsedExpires), 'Comparing Expires ' . \var_export($p['Expires'], true) . ' : ' . \var_export($parsed, true) . ' | ' . \var_export($p, true));
408+
unset($p['Expires']);
409+
unset($parsed['Expires']);
424410
}
425411

426412
if (!empty($parsed)) {
@@ -479,9 +465,6 @@ public function isExpiredProvider(): array
479465

480466
/**
481467
* @dataProvider isExpiredProvider
482-
*
483-
* @param string $cookie
484-
* @param bool $expired
485468
*/
486469
public function testIsExpired(string $cookie, bool $expired): void
487470
{

0 commit comments

Comments
 (0)