Browse Source

Renamed convertCookie() to convertCookieToArray() and make them protected.

Robert Pustułka 9 years ago
parent
commit
d5ae143163

+ 2 - 2
src/Http/Client/CookieCollection.php

@@ -79,7 +79,7 @@ class CookieCollection extends BaseCollection
     {
         $out = [];
         foreach ($this->cookies as $cookie) {
-            $out[] = $this->convertCookie($cookie);
+            $out[] = $this->convertCookieToArray($cookie);
         }
 
         return $out;
@@ -93,7 +93,7 @@ class CookieCollection extends BaseCollection
      * @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
      * @return array
      */
-    public function convertCookie(CookieInterface $cookie)
+    protected function convertCookieToArray(CookieInterface $cookie)
     {
         return [
             'name' => $cookie->getName(),

+ 3 - 3
src/Http/Client/Response.php

@@ -446,7 +446,7 @@ class Response extends Message implements ResponseInterface
 
         $cookie = $this->cookies->get($name);
 
-        return $this->convertCookie($cookie);
+        return $this->convertCookieToArray($cookie);
     }
 
     /**
@@ -458,7 +458,7 @@ class Response extends Message implements ResponseInterface
      * @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
      * @return array
      */
-    public function convertCookie(CookieInterface $cookie)
+    protected function convertCookieToArray(CookieInterface $cookie)
     {
         return [
             'name' => $cookie->getName(),
@@ -495,7 +495,7 @@ class Response extends Message implements ResponseInterface
 
         $cookies = [];
         foreach ($this->cookies as $cookie) {
-            $cookies[$cookie->getName()] = $this->convertCookie($cookie);
+            $cookies[$cookie->getName()] = $this->convertCookieToArray($cookie);
         }
 
         return $cookies;

+ 4 - 4
src/Http/Response.php

@@ -1941,7 +1941,7 @@ class Response implements ResponseInterface
 
             $cookie = $this->_cookies->get($options);
 
-            return $this->convertCookie($cookie);
+            return $this->convertCookieToArray($cookie);
         }
 
         $options += [
@@ -2047,7 +2047,7 @@ class Response implements ResponseInterface
 
         $cookie = $this->_cookies->get($name);
 
-        return $this->convertCookie($cookie);
+        return $this->convertCookieToArray($cookie);
     }
 
     /**
@@ -2061,7 +2061,7 @@ class Response implements ResponseInterface
     {
         $out = [];
         foreach ($this->_cookies as $cookie) {
-            $out[$cookie->getName()] = $this->convertCookie($cookie);
+            $out[$cookie->getName()] = $this->convertCookieToArray($cookie);
         }
 
         return $out;
@@ -2076,7 +2076,7 @@ class Response implements ResponseInterface
      * @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
      * @return array
      */
-    public function convertCookie(CookieInterface $cookie)
+    protected function convertCookieToArray(CookieInterface $cookie)
     {
         return [
             'name' => $cookie->getName(),

+ 0 - 26
tests/TestCase/Http/Client/CookieCollectionTest.php

@@ -303,30 +303,4 @@ class CookieCollectionTest extends TestCase
         $expected = [];
         $this->assertEquals($expected, $result);
     }
-
-    /**
-     * Test convertCookie
-     *
-     * @return void
-     */
-    public function testConvertCookie()
-    {
-        $date = Chronos::parse('2017-03-31 12:34:56');
-        $cookie = new Cookie('cakephp', 'cakephp-rocks');
-        $cookie = $cookie->withDomain('cakephp.org')
-            ->withPath('/api')
-            ->withExpiry($date)
-            ->withHttpOnly(true)
-            ->withSecure(true);
-        $expected = [
-            'name' => 'cakephp',
-            'value' => 'cakephp-rocks',
-            'path' => '/api',
-            'domain' => 'cakephp.org',
-            'expires' => $date->format('U'),
-            'secure' => true,
-            'httponly' => true
-        ];
-        $this->assertEquals($expected, $this->cookies->convertCookie($cookie));
-    }
 }

+ 0 - 27
tests/TestCase/Http/Client/ResponseTest.php

@@ -430,31 +430,4 @@ XML;
         $response = new Response($headers, $body);
         $this->assertEquals('Hello world!', $response->body);
     }
-
-    /**
-     * Test convertCookie
-     *
-     * @return void
-     */
-    public function testConvertCookie()
-    {
-        $date = Chronos::parse('2017-03-31 12:34:56');
-        $cookie = new Cookie('cakephp', 'cakephp-rocks');
-        $cookie = $cookie->withDomain('cakephp.org')
-            ->withPath('/api')
-            ->withExpiry($date)
-            ->withHttpOnly(true)
-            ->withSecure(true);
-        $expected = [
-            'name' => 'cakephp',
-            'value' => 'cakephp-rocks',
-            'path' => '/api',
-            'domain' => 'cakephp.org',
-            'expires' => 'Fri, 31-Mar-2017 12:34:56 GMT',
-            'secure' => true,
-            'httponly' => true
-        ];
-        $response = new Response([], '');
-        $this->assertEquals($expected, $response->convertCookie($cookie));
-    }
 }

+ 0 - 27
tests/TestCase/Http/ResponseTest.php

@@ -3051,31 +3051,4 @@ class ResponseTest extends TestCase
         ];
         $this->assertEquals($expected, $result);
     }
-
-    /**
-     * Test convertCookie
-     *
-     * @return void
-     */
-    public function testConvertCookie()
-    {
-        $date = Chronos::parse('2017-03-31 12:34:56');
-        $cookie = new Cookie('cakephp', 'cakephp-rocks');
-        $cookie = $cookie->withDomain('cakephp.org')
-            ->withPath('/api')
-            ->withExpiry($date)
-            ->withHttpOnly(true)
-            ->withSecure(true);
-        $expected = [
-            'name' => 'cakephp',
-            'value' => 'cakephp-rocks',
-            'path' => '/api',
-            'domain' => 'cakephp.org',
-            'expire' => $date->format('U'),
-            'secure' => true,
-            'httpOnly' => true
-        ];
-        $response = new Response();
-        $this->assertEquals($expected, $response->convertCookie($cookie));
-    }
 }