@@ -162,6 +162,132 @@ public function testStatusCodeNotEquals()
162162 );
163163 }
164164
165+ public function testResponseHeaderEquals ()
166+ {
167+ $ this ->session
168+ ->expects ($ this ->any ())
169+ ->method ('getResponseHeader ' )
170+ ->will ($ this ->returnValueMap (
171+ array (
172+ array ('foo ' , 'bar ' ),
173+ array ('bar ' , 'baz ' ),
174+ )
175+ ));
176+
177+ $ this ->assertCorrectAssertion ('responseHeaderEquals ' , array ('foo ' , 'bar ' ));
178+ $ this ->assertWrongAssertion (
179+ 'responseHeaderEquals ' ,
180+ array ('bar ' , 'foo ' ),
181+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
182+ 'Current response header "bar" is "baz", but "foo" expected. '
183+ );
184+ }
185+
186+ public function testResponseHeaderNotEquals ()
187+ {
188+ $ this ->session
189+ ->expects ($ this ->any ())
190+ ->method ('getResponseHeader ' )
191+ ->will ($ this ->returnValueMap (
192+ array (
193+ array ('foo ' , 'bar ' ),
194+ array ('bar ' , 'baz ' ),
195+ )
196+ ));
197+
198+ $ this ->assertCorrectAssertion ('responseHeaderNotEquals ' , array ('foo ' , 'baz ' ));
199+ $ this ->assertWrongAssertion (
200+ 'responseHeaderNotEquals ' ,
201+ array ('bar ' , 'baz ' ),
202+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
203+ 'Current response header "bar" is "baz", but should not be. '
204+ );
205+ }
206+
207+ public function testResponseHeaderContains ()
208+ {
209+ $ this ->session
210+ ->expects ($ this ->any ())
211+ ->method ('getResponseHeader ' )
212+ ->will ($ this ->returnValueMap (
213+ array (
214+ array ('foo ' , 'bar ' ),
215+ array ('bar ' , 'baz ' ),
216+ )
217+ ));
218+
219+ $ this ->assertCorrectAssertion ('responseHeaderContains ' , array ('foo ' , 'ba ' ));
220+ $ this ->assertWrongAssertion (
221+ 'responseHeaderContains ' ,
222+ array ('bar ' , 'bz ' ),
223+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
224+ 'The text "bz" was not found anywhere in the "bar" response header. '
225+ );
226+ }
227+
228+ public function testResponseHeaderNotContains ()
229+ {
230+ $ this ->session
231+ ->expects ($ this ->any ())
232+ ->method ('getResponseHeader ' )
233+ ->will ($ this ->returnValueMap (
234+ array (
235+ array ('foo ' , 'bar ' ),
236+ array ('bar ' , 'baz ' ),
237+ )
238+ ));
239+
240+ $ this ->assertCorrectAssertion ('responseHeaderNotContains ' , array ('foo ' , 'bz ' ));
241+ $ this ->assertWrongAssertion (
242+ 'responseHeaderNotContains ' ,
243+ array ('bar ' , 'ba ' ),
244+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
245+ 'The text "ba" was found in the "bar" response header, but it should not. '
246+ );
247+ }
248+
249+ public function testResponseHeaderMatches ()
250+ {
251+ $ this ->session
252+ ->expects ($ this ->any ())
253+ ->method ('getResponseHeader ' )
254+ ->will ($ this ->returnValueMap (
255+ array (
256+ array ('foo ' , 'bar ' ),
257+ array ('bar ' , 'baz ' ),
258+ )
259+ ));
260+
261+ $ this ->assertCorrectAssertion ('responseHeaderMatches ' , array ('foo ' , '/ba(.*)/ ' ));
262+ $ this ->assertWrongAssertion (
263+ 'responseHeaderMatches ' ,
264+ array ('bar ' , '/b[^a]/ ' ),
265+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
266+ 'The pattern "/b[^a]/" was not found anywhere in the "bar" response header. '
267+ );
268+ }
269+
270+ public function testResponseHeaderNotMatches ()
271+ {
272+ $ this ->session
273+ ->expects ($ this ->any ())
274+ ->method ('getResponseHeader ' )
275+ ->will ($ this ->returnValueMap (
276+ array (
277+ array ('foo ' , 'bar ' ),
278+ array ('bar ' , 'baz ' ),
279+ )
280+ ));
281+
282+ $ this ->assertCorrectAssertion ('responseHeaderNotMatches ' , array ('foo ' , '/bz/ ' ));
283+ $ this ->assertWrongAssertion (
284+ 'responseHeaderNotMatches ' ,
285+ array ('bar ' , '/b[ab]z/ ' ),
286+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
287+ 'The pattern "/b[ab]z/" was found in the text of the "bar" response header, but it should not. '
288+ );
289+ }
290+
165291 public function testPageTextContains ()
166292 {
167293 $ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
0 commit comments