@@ -116,11 +116,11 @@ public function testToStringIncludesCookieHeaders()
116
116
$ bag = new ResponseHeaderBag (array ());
117
117
$ bag ->setCookie (new Cookie ('foo ' , 'bar ' ));
118
118
119
- $ this ->assertContains ( ' Set-Cookie: foo=bar; path=/; httponly ' , explode ( "\r\n" , $ bag-> __toString ()) );
119
+ $ this ->assertSetCookieHeader ( ' foo=bar; path=/; httponly ' , $ bag );
120
120
121
121
$ bag ->clearCookie ('foo ' );
122
122
123
- $ this ->assertRegExp ( ' #^Set-Cookie: foo=deleted; expires= ' .gmdate ('D, d-M-Y H:i:s T ' , time () - 31536001 ).'; path=/; httponly#m ' , $ bag-> __toString () );
123
+ $ this ->assertSetCookieHeader ( ' foo=deleted; expires= ' .gmdate ('D, d-M-Y H:i:s T ' , time () - 31536001 ).'; path=/; httponly ' , $ bag );
124
124
}
125
125
126
126
public function testClearCookieSecureNotHttpOnly ()
@@ -129,7 +129,7 @@ public function testClearCookieSecureNotHttpOnly()
129
129
130
130
$ bag ->clearCookie ('foo ' , '/ ' , null , true , false );
131
131
132
- $ this ->assertRegExp ( ' #^Set-Cookie: foo=deleted; expires= ' .gmdate ('D, d-M-Y H:i:s T ' , time () - 31536001 ).'; path=/; secure#m ' , $ bag-> __toString () );
132
+ $ this ->assertSetCookieHeader ( ' foo=deleted; expires= ' .gmdate ('D, d-M-Y H:i:s T ' , time () - 31536001 ).'; path=/; secure ' , $ bag );
133
133
}
134
134
135
135
public function testReplace ()
@@ -165,11 +165,10 @@ public function testCookiesWithSameNames()
165
165
166
166
$ this ->assertCount (4 , $ bag ->getCookies ());
167
167
168
- $ headers = explode ("\r\n" , $ bag ->__toString ());
169
- $ this ->assertContains ('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly ' , $ headers );
170
- $ this ->assertContains ('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly ' , $ headers );
171
- $ this ->assertContains ('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly ' , $ headers );
172
- $ this ->assertContains ('Set-Cookie: foo=bar; path=/; httponly ' , $ headers );
168
+ $ this ->assertSetCookieHeader ('foo=bar; path=/path/foo; domain=foo.bar; httponly ' , $ bag );
169
+ $ this ->assertSetCookieHeader ('foo=bar; path=/path/bar; domain=foo.bar; httponly ' , $ bag );
170
+ $ this ->assertSetCookieHeader ('foo=bar; path=/path/bar; domain=bar.foo; httponly ' , $ bag );
171
+ $ this ->assertSetCookieHeader ('foo=bar; path=/; httponly ' , $ bag );
173
172
174
173
$ cookies = $ bag ->getCookies (ResponseHeaderBag::COOKIES_ARRAY );
175
174
$ this ->assertTrue (isset ($ cookies ['foo.bar ' ]['/path/foo ' ]['foo ' ]));
@@ -223,7 +222,7 @@ public function testGetCookiesWithInvalidArgument()
223
222
{
224
223
$ bag = new ResponseHeaderBag ();
225
224
226
- $ cookies = $ bag ->getCookies ('invalid_argument ' );
225
+ $ bag ->getCookies ('invalid_argument ' );
227
226
}
228
227
229
228
/**
@@ -294,4 +293,9 @@ public function provideMakeDispositionFail()
294
293
array ('attachment ' , 'föö.html ' ),
295
294
);
296
295
}
296
+
297
+ private function assertSetCookieHeader ($ expected , ResponseHeaderBag $ actual )
298
+ {
299
+ $ this ->assertRegExp ('#^Set-Cookie:\s+ ' .preg_quote ($ expected , '# ' ).'$#m ' , str_replace ("\r\n" , "\n" , (string ) $ actual ));
300
+ }
297
301
}
0 commit comments