@@ -63,25 +63,33 @@ public function testUpdateFromResponse()
63
63
$ response = new Response ('' , 200 , array ('Set-Cookie ' => 'foo=foo ' ));
64
64
65
65
$ cookieJar = new CookieJar ();
66
- $ cookieJar ->set (new Cookie ('bar ' , 'bar ' ));
67
66
$ cookieJar ->updateFromResponse ($ response );
68
67
68
+ $ this ->assertEquals ('foo ' , $ cookieJar ->get ('foo ' )->getValue (), '->updateFromResponse() updates cookies from a Response objects ' );
69
+ }
70
+
71
+ public function testUpdateFromSetCookie ()
72
+ {
73
+ $ setCookies = array ('foo=foo ' );
74
+
75
+ $ cookieJar = new CookieJar ();
76
+ $ cookieJar ->set (new Cookie ('bar ' , 'bar ' ));
77
+ $ cookieJar ->updateFromSetCookie ($ setCookies );
78
+
69
79
$ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ cookieJar ->get ('foo ' ));
70
80
$ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ cookieJar ->get ('bar ' ));
71
- $ this ->assertEquals ('foo ' , $ cookieJar ->get ('foo ' )->getValue (), '->updateFromResponse () updates cookies from a Response objects ' );
72
- $ this ->assertEquals ('bar ' , $ cookieJar ->get ('bar ' )->getValue (), '->updateFromResponse () keeps existing cookies ' );
81
+ $ this ->assertEquals ('foo ' , $ cookieJar ->get ('foo ' )->getValue (), '->updateFromSetCookie () updates cookies from a Set-Cookie header ' );
82
+ $ this ->assertEquals ('bar ' , $ cookieJar ->get ('bar ' )->getValue (), '->updateFromSetCookie () keeps existing cookies ' );
73
83
}
74
84
75
- public function testUpdateFromResponseWithMultipleCookies ()
85
+ public function testUpdateFromSetCookieWithMultipleCookies ()
76
86
{
77
87
$ timestamp = time () + 3600 ;
78
88
$ date = gmdate ('D, d M Y H:i:s \G\M\T ' , $ timestamp );
79
- $ response = new Response ('' , 200 , array (
80
- 'Set-Cookie ' => sprintf ('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%s ' , $ date , $ date )
81
- ));
89
+ $ setCookies = array (sprintf ('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%s ' , $ date , $ date ));
82
90
83
91
$ cookieJar = new CookieJar ();
84
- $ cookieJar ->updateFromResponse ( $ response );
92
+ $ cookieJar ->updateFromSetCookie ( $ setCookies );
85
93
86
94
$ fooCookie = $ cookieJar ->get ('foo ' , '/ ' , '.symfony.com ' );
87
95
$ barCookie = $ cookieJar ->get ('bar ' , '/ ' , '.blog.symfony.com ' );
0 commit comments