[BrowserKit] fixed cookie management

This commit is contained in:
Fabien Potencier 2010-04-22 07:22:44 +02:00
parent 20527a0a5b
commit ab7adbff2b
2 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,6 @@ class CookieJar
*/ */
public function updateFromResponse(Response $response) public function updateFromResponse(Response $response)
{ {
$this->clear();
foreach ($response->getCookies() as $name => $cookie) foreach ($response->getCookies() as $name => $cookie)
{ {
$this->set(new Cookie( $this->set(new Cookie(

View File

@ -191,11 +191,12 @@ class ClientTest extends \PHPUnit_Framework_TestCase
public function testRequestCookies() public function testRequestCookies()
{ {
$client = new TestClient(); $client = new TestClient();
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array(), array('foo' => array('value' => 'bar'))));
$client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'http://www.example.com/foo/foobar');
$this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->getValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
$client->request('GET', 'bar'); $client->request('GET', 'bar');
RETURN; $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->getValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
$this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History');
$this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History');
} }
public function testClick() public function testClick()