Skip to content

Commit

Permalink
Merge pull request #128 from littleredbutton/updated-set-cookie-test
Browse files Browse the repository at this point in the history
Updated SetCookieTest to pull fix from Guzzle
  • Loading branch information
sualko committed Mar 17, 2022
2 parents 2a92906 + cdcfb98 commit cb66dda
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions tests/unit/Http/SetCookieTest.php
Expand Up @@ -170,10 +170,6 @@ public function pathMatchProvider(): array

/**
* @dataProvider pathMatchProvider
*
* @param string $cookiePath
* @param string $requestPath
* @param bool $isMatch
*/
public function testMatchesPath(string $cookiePath, string $requestPath, bool $isMatch): void
{
Expand All @@ -199,9 +195,6 @@ public function cookieValidateProvider(): array
/**
* @dataProvider cookieValidateProvider
*
* @param string $name
* @param string|null $value
* @param string $domain
* @param bool|string $result
*/
public function testValidatesCookies(string $name, ?string $value, string $domain, $result): void
Expand Down Expand Up @@ -401,26 +394,19 @@ public function cookieParserDataProvider(): array
* @dataProvider cookieParserDataProvider
*
* @param string|array $cookie
* @param array $parsed
*/
public function testParseCookie($cookie, array $parsed): void
{
if (\PHP_VERSION_ID >= 80000) {
self::markTestSkipped('This test is possibly using incorrect code and is broken starting from PHP 8. ' .
'See https://github.com/littleredbutton/bigbluebutton-api-php/pull/70#discussion_r637602067 and ' .
'https://github.com/guzzle/guzzle/issues/2894 for details.');
}

foreach ((array) $cookie as $v) {
$c = SetCookie::fromString($v);
$p = $c->toArray();

if (isset($p['Expires'])) {
// Remove expires values from the assertion if they are relatively equal
if (\abs($p['Expires'] != \strtotime((string) $parsed['Expires'])) < 40) {
unset($p['Expires']);
unset($parsed['Expires']);
}
$delta = 40;
$parsedExpires = \is_numeric($parsed['Expires']) ? $parsed['Expires'] : \strtotime($parsed['Expires']);
self::assertLessThan($delta, \abs($p['Expires'] - $parsedExpires), 'Comparing Expires ' . \var_export($p['Expires'], true) . ' : ' . \var_export($parsed, true) . ' | ' . \var_export($p, true));
unset($p['Expires']);
unset($parsed['Expires']);
}

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

/**
* @dataProvider isExpiredProvider
*
* @param string $cookie
* @param bool $expired
*/
public function testIsExpired(string $cookie, bool $expired): void
{
Expand Down

0 comments on commit cb66dda

Please sign in to comment.