mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 18:13:00 +01:00
Adding some missing cookie jar tests
This commit is contained in:
parent
a933648121
commit
05976ee2b1
@ -29,6 +29,12 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testQuotesBadCookieValues()
|
||||||
|
{
|
||||||
|
$this->assertEquals('foo', CookieJar::getCookieValue('foo'));
|
||||||
|
$this->assertEquals('"foo,bar"', CookieJar::getCookieValue('foo,bar'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreatesFromArray()
|
public function testCreatesFromArray()
|
||||||
{
|
{
|
||||||
$jar = CookieJar::fromArray([
|
$jar = CookieJar::fromArray([
|
||||||
@ -293,4 +299,27 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
|||||||
$a = new CookieJar(true);
|
$a = new CookieJar(true);
|
||||||
$a->setCookie(new SetCookie(['Name' => "abc\n", 'Value' => 'foo', 'Domain' => 'bar']));
|
$a->setCookie(new SetCookie(['Name' => "abc\n", 'Value' => 'foo', 'Domain' => 'bar']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDeletesCookiesByName()
|
||||||
|
{
|
||||||
|
$cookies = $this->getTestCookies();
|
||||||
|
$cookies[] = new SetCookie([
|
||||||
|
'Name' => 'other',
|
||||||
|
'Value' => '123',
|
||||||
|
'Domain' => 'bar.com',
|
||||||
|
'Path' => '/boo',
|
||||||
|
'Expires' => time() + 1000
|
||||||
|
]);
|
||||||
|
$jar = new CookieJar();
|
||||||
|
foreach ($cookies as $cookie) {
|
||||||
|
$jar->setCookie($cookie);
|
||||||
|
}
|
||||||
|
$this->assertCount(4, $jar);
|
||||||
|
$jar->clear('bar.com', '/boo', 'other');
|
||||||
|
$this->assertCount(3, $jar);
|
||||||
|
$names = array_map(function (SetCookie $c) {
|
||||||
|
return $c->getName();
|
||||||
|
}, $jar->getIterator()->getArrayCopy());
|
||||||
|
$this->assertEquals(['foo', 'test', 'you'], $names);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user