Skip to content

Commit d5ae143

Browse files
author
Robert Pustułka
committed
Renamed convertCookie() to convertCookieToArray() and make them protected.
1 parent 74e1c4f commit d5ae143

File tree

6 files changed

+9
-89
lines changed

6 files changed

+9
-89
lines changed

src/Http/Client/CookieCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getAll()
7979
{
8080
$out = [];
8181
foreach ($this->cookies as $cookie) {
82-
$out[] = $this->convertCookie($cookie);
82+
$out[] = $this->convertCookieToArray($cookie);
8383
}
8484

8585
return $out;
@@ -93,7 +93,7 @@ public function getAll()
9393
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
9494
* @return array
9595
*/
96-
public function convertCookie(CookieInterface $cookie)
96+
protected function convertCookieToArray(CookieInterface $cookie)
9797
{
9898
return [
9999
'name' => $cookie->getName(),

src/Http/Client/Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public function getCookieData($name)
446446

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

449-
return $this->convertCookie($cookie);
449+
return $this->convertCookieToArray($cookie);
450450
}
451451

452452
/**
@@ -458,7 +458,7 @@ public function getCookieData($name)
458458
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
459459
* @return array
460460
*/
461-
public function convertCookie(CookieInterface $cookie)
461+
protected function convertCookieToArray(CookieInterface $cookie)
462462
{
463463
return [
464464
'name' => $cookie->getName(),
@@ -495,7 +495,7 @@ protected function _getCookies()
495495

496496
$cookies = [];
497497
foreach ($this->cookies as $cookie) {
498-
$cookies[$cookie->getName()] = $this->convertCookie($cookie);
498+
$cookies[$cookie->getName()] = $this->convertCookieToArray($cookie);
499499
}
500500

501501
return $cookies;

src/Http/Response.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ public function cookie($options = null)
19411941

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

1944-
return $this->convertCookie($cookie);
1944+
return $this->convertCookieToArray($cookie);
19451945
}
19461946

19471947
$options += [
@@ -2047,7 +2047,7 @@ public function getCookie($name)
20472047

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

2050-
return $this->convertCookie($cookie);
2050+
return $this->convertCookieToArray($cookie);
20512051
}
20522052

20532053
/**
@@ -2061,7 +2061,7 @@ public function getCookies()
20612061
{
20622062
$out = [];
20632063
foreach ($this->_cookies as $cookie) {
2064-
$out[$cookie->getName()] = $this->convertCookie($cookie);
2064+
$out[$cookie->getName()] = $this->convertCookieToArray($cookie);
20652065
}
20662066

20672067
return $out;
@@ -2076,7 +2076,7 @@ public function getCookies()
20762076
* @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
20772077
* @return array
20782078
*/
2079-
public function convertCookie(CookieInterface $cookie)
2079+
protected function convertCookieToArray(CookieInterface $cookie)
20802080
{
20812081
return [
20822082
'name' => $cookie->getName(),

tests/TestCase/Http/Client/CookieCollectionTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -303,30 +303,4 @@ public function testGetMatchingDomainWithDot()
303303
$expected = [];
304304
$this->assertEquals($expected, $result);
305305
}
306-
307-
/**
308-
* Test convertCookie
309-
*
310-
* @return void
311-
*/
312-
public function testConvertCookie()
313-
{
314-
$date = Chronos::parse('2017-03-31 12:34:56');
315-
$cookie = new Cookie('cakephp', 'cakephp-rocks');
316-
$cookie = $cookie->withDomain('cakephp.org')
317-
->withPath('/api')
318-
->withExpiry($date)
319-
->withHttpOnly(true)
320-
->withSecure(true);
321-
$expected = [
322-
'name' => 'cakephp',
323-
'value' => 'cakephp-rocks',
324-
'path' => '/api',
325-
'domain' => 'cakephp.org',
326-
'expires' => $date->format('U'),
327-
'secure' => true,
328-
'httponly' => true
329-
];
330-
$this->assertEquals($expected, $this->cookies->convertCookie($cookie));
331-
}
332306
}

tests/TestCase/Http/Client/ResponseTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -430,31 +430,4 @@ public function testAutoDecodeGzipBody()
430430
$response = new Response($headers, $body);
431431
$this->assertEquals('Hello world!', $response->body);
432432
}
433-
434-
/**
435-
* Test convertCookie
436-
*
437-
* @return void
438-
*/
439-
public function testConvertCookie()
440-
{
441-
$date = Chronos::parse('2017-03-31 12:34:56');
442-
$cookie = new Cookie('cakephp', 'cakephp-rocks');
443-
$cookie = $cookie->withDomain('cakephp.org')
444-
->withPath('/api')
445-
->withExpiry($date)
446-
->withHttpOnly(true)
447-
->withSecure(true);
448-
$expected = [
449-
'name' => 'cakephp',
450-
'value' => 'cakephp-rocks',
451-
'path' => '/api',
452-
'domain' => 'cakephp.org',
453-
'expires' => 'Fri, 31-Mar-2017 12:34:56 GMT',
454-
'secure' => true,
455-
'httponly' => true
456-
];
457-
$response = new Response([], '');
458-
$this->assertEquals($expected, $response->convertCookie($cookie));
459-
}
460433
}

tests/TestCase/Http/ResponseTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,31 +3051,4 @@ public function testDebugInfo()
30513051
];
30523052
$this->assertEquals($expected, $result);
30533053
}
3054-
3055-
/**
3056-
* Test convertCookie
3057-
*
3058-
* @return void
3059-
*/
3060-
public function testConvertCookie()
3061-
{
3062-
$date = Chronos::parse('2017-03-31 12:34:56');
3063-
$cookie = new Cookie('cakephp', 'cakephp-rocks');
3064-
$cookie = $cookie->withDomain('cakephp.org')
3065-
->withPath('/api')
3066-
->withExpiry($date)
3067-
->withHttpOnly(true)
3068-
->withSecure(true);
3069-
$expected = [
3070-
'name' => 'cakephp',
3071-
'value' => 'cakephp-rocks',
3072-
'path' => '/api',
3073-
'domain' => 'cakephp.org',
3074-
'expire' => $date->format('U'),
3075-
'secure' => true,
3076-
'httpOnly' => true
3077-
];
3078-
$response = new Response();
3079-
$this->assertEquals($expected, $response->convertCookie($cookie));
3080-
}
30813054
}

0 commit comments

Comments
 (0)