/** * @dataProvider cookieParserDataProvider */ public function testParseCookie($cookie, $parsed) { foreach ((array) $cookie as $v) { $c = puzzle_cookie_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($parsed['Expires'])) < 40) { unset($p['Expires']); unset($parsed['Expires']); } } if (!empty($parsed)) { foreach ($parsed as $key => $value) { $this->assertEquals($parsed[$key], $p[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true)); } foreach ($p as $key => $value) { $this->assertEquals($p[$key], $parsed[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true)); } } else { $this->assertEquals(array('Name' => null, 'Value' => null, 'Domain' => null, 'Path' => '/', 'Max-Age' => null, 'Expires' => null, 'Secure' => false, 'Discard' => false, 'HttpOnly' => false), $p); } } }
public function __callback_testDeletesCookiesByName(puzzle_cookie_SetCookie $c) { return $c->getName(); }
/** * If a cookie already exists and the server asks to set it again with a * null value, the cookie must be deleted. * * @param puzzle_cookie_SetCookie $cookie */ private function removeCookieIfEmpty(puzzle_cookie_SetCookie $cookie) { $cookieValue = $cookie->getValue(); if ($cookieValue === null || $cookieValue === '') { $this->clear($cookie->getDomain(), $cookie->getPath(), $cookie->getName()); } }