Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated SetCookieTest to pull fix from Guzzle #128

Merged
merged 2 commits into from Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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