Skip to content

Commit

Permalink
Renamed convertCookie() to convertCookieToArray() and make them prote…
Browse files Browse the repository at this point in the history
…cted.
  • Loading branch information
Robert Pustułka committed Apr 25, 2017
1 parent 74e1c4f commit d5ae143
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/Http/Client/CookieCollection.php
Expand Up @@ -79,7 +79,7 @@ public function getAll()
{
$out = [];
foreach ($this->cookies as $cookie) {
$out[] = $this->convertCookie($cookie);
$out[] = $this->convertCookieToArray($cookie);
}

return $out;
Expand All @@ -93,7 +93,7 @@ public function getAll()
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
* @return array
*/
public function convertCookie(CookieInterface $cookie)
protected function convertCookieToArray(CookieInterface $cookie)
{
return [
'name' => $cookie->getName(),
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Client/Response.php
Expand Up @@ -446,7 +446,7 @@ public function getCookieData($name)

$cookie = $this->cookies->get($name);

return $this->convertCookie($cookie);
return $this->convertCookieToArray($cookie);
}

/**
Expand All @@ -458,7 +458,7 @@ public function getCookieData($name)
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
* @return array
*/
public function convertCookie(CookieInterface $cookie)
protected function convertCookieToArray(CookieInterface $cookie)
{
return [
'name' => $cookie->getName(),
Expand Down Expand Up @@ -495,7 +495,7 @@ protected function _getCookies()

$cookies = [];
foreach ($this->cookies as $cookie) {
$cookies[$cookie->getName()] = $this->convertCookie($cookie);
$cookies[$cookie->getName()] = $this->convertCookieToArray($cookie);
}

return $cookies;
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Response.php
Expand Up @@ -1941,7 +1941,7 @@ public function cookie($options = null)

$cookie = $this->_cookies->get($options);

return $this->convertCookie($cookie);
return $this->convertCookieToArray($cookie);
}

$options += [
Expand Down Expand Up @@ -2047,7 +2047,7 @@ public function getCookie($name)

$cookie = $this->_cookies->get($name);

return $this->convertCookie($cookie);
return $this->convertCookieToArray($cookie);
}

/**
Expand All @@ -2061,7 +2061,7 @@ public function getCookies()
{
$out = [];
foreach ($this->_cookies as $cookie) {
$out[$cookie->getName()] = $this->convertCookie($cookie);
$out[$cookie->getName()] = $this->convertCookieToArray($cookie);
}

return $out;
Expand All @@ -2076,7 +2076,7 @@ public function getCookies()
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
* @return array
*/
public function convertCookie(CookieInterface $cookie)
protected function convertCookieToArray(CookieInterface $cookie)
{
return [
'name' => $cookie->getName(),
Expand Down
26 changes: 0 additions & 26 deletions tests/TestCase/Http/Client/CookieCollectionTest.php
Expand Up @@ -303,30 +303,4 @@ public function testGetMatchingDomainWithDot()
$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));
}
}
27 changes: 0 additions & 27 deletions tests/TestCase/Http/Client/ResponseTest.php
Expand Up @@ -430,31 +430,4 @@ public function testAutoDecodeGzipBody()
$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));
}
}
27 changes: 0 additions & 27 deletions tests/TestCase/Http/ResponseTest.php
Expand Up @@ -3051,31 +3051,4 @@ public function testDebugInfo()
];
$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));
}
}

0 comments on commit d5ae143

Please sign in to comment.