Browse Source

Use undeprecated method when storing cookies from responses.

Mark Story 9 years ago
parent
commit
87d90622b1
2 changed files with 5 additions and 12 deletions
  1. 1 1
      src/Http/Client.php
  2. 4 11
      tests/TestCase/Http/ClientTest.php

+ 1 - 1
src/Http/Client.php

@@ -374,7 +374,7 @@ class Client
         $responses = $this->_adapter->send($request, $options);
         $url = $request->getUri();
         foreach ($responses as $response) {
-            $this->_cookies->store($response, $url);
+            $this->_cookies = $this->_cookies->addFromResponse($response, $request);
         }
 
         return array_pop($responses);

+ 4 - 11
tests/TestCase/Http/ClientTest.php

@@ -597,7 +597,6 @@ class ClientTest extends TestCase
         $adapter = $this->getMockBuilder('Cake\Http\Client\Adapter\Stream')
             ->setMethods(['send'])
             ->getMock();
-        $cookieJar = $this->getMockBuilder('Cake\Http\Client\CookieCollection')->getMock();
 
         $headers = [
             'HTTP/1.0 200 Ok',
@@ -605,16 +604,6 @@ class ClientTest extends TestCase
             'Set-Cookie: expiring=now; Expires=Wed, 09-Jun-1999 10:18:14 GMT'
         ];
         $response = new Response($headers, '');
-
-        $cookieJar->expects($this->at(0))
-            ->method('get')
-            ->with('http://cakephp.org/projects')
-            ->will($this->returnValue([]));
-
-        $cookieJar->expects($this->at(1))
-            ->method('store')
-            ->with($response);
-
         $adapter->expects($this->at(0))
             ->method('send')
             ->will($this->returnValue([$response]));
@@ -626,6 +615,10 @@ class ClientTest extends TestCase
         ]);
 
         $http->get('/projects');
+        $cookies = $http->cookies();
+        $this->assertCount(1, $cookies);
+        $this->assertTrue($cookies->has('first'));
+        $this->assertFalse($cookies->has('expiring'));
     }
 
     /**