소스 검색

[BrowserKit] fixed cookie management

Fabien Potencier 15 년 전
부모
커밋
ab7adbff2b
2개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 0 1
      src/Symfony/Components/BrowserKit/CookieJar.php
  2. 4 3
      tests/Symfony/Tests/Components/BrowserKit/ClientTest.php

+ 0 - 1
src/Symfony/Components/BrowserKit/CookieJar.php

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

+ 4 - 3
tests/Symfony/Tests/Components/BrowserKit/ClientTest.php

@@ -191,11 +191,12 @@ class ClientTest extends \PHPUnit_Framework_TestCase
   public function testRequestCookies()
   {
     $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');
+    $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->getValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
+
     $client->request('GET', 'bar');
-RETURN;
-    $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');
+    $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->getValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
   }
 
   public function testClick()