@@ -66,10 +66,38 @@ public function testUpdateFromResponse()
66
66
$ cookieJar ->set (new Cookie ('bar ' , 'bar ' ));
67
67
$ cookieJar ->updateFromResponse ($ response );
68
68
69
+ $ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ cookieJar ->get ('foo ' ));
70
+ $ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ cookieJar ->get ('bar ' ));
69
71
$ this ->assertEquals ('foo ' , $ cookieJar ->get ('foo ' )->getValue (), '->updateFromResponse() updates cookies from a Response objects ' );
70
72
$ this ->assertEquals ('bar ' , $ cookieJar ->get ('bar ' )->getValue (), '->updateFromResponse() keeps existing cookies ' );
71
73
}
72
74
75
+ public function testUpdateFromResponseWithMultipleCookies ()
76
+ {
77
+ $ timestamp = time () + 3600 ;
78
+ $ 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
+ ));
82
+
83
+ $ cookieJar = new CookieJar ();
84
+ $ cookieJar ->updateFromResponse ($ response );
85
+
86
+ $ fooCookie = $ cookieJar ->get ('foo ' , '/ ' , '.symfony.com ' );
87
+ $ barCookie = $ cookieJar ->get ('bar ' , '/ ' , '.blog.symfony.com ' );
88
+ $ phpCookie = $ cookieJar ->get ('PHPSESSID ' );
89
+
90
+ $ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ fooCookie );
91
+ $ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ barCookie );
92
+ $ this ->assertInstanceOf ('Symfony\Component\BrowserKit\Cookie ' , $ phpCookie );
93
+ $ this ->assertEquals ('foo ' , $ fooCookie ->getValue ());
94
+ $ this ->assertEquals ('bar ' , $ barCookie ->getValue ());
95
+ $ this ->assertEquals ('id ' , $ phpCookie ->getValue ());
96
+ $ this ->assertEquals ($ timestamp , $ fooCookie ->getExpiresTime ());
97
+ $ this ->assertEquals (null , $ barCookie ->getExpiresTime ());
98
+ $ this ->assertEquals ($ timestamp , $ phpCookie ->getExpiresTime ());
99
+ }
100
+
73
101
/**
74
102
* @dataProvider provideAllValuesValues
75
103
*/
0 commit comments