3
3
namespace Behat \Mink \Tests ;
4
4
5
5
use Behat \Mink \Exception \ExpectationException ;
6
- use Behat \Mink \Tests \helpers \Stringer ;
6
+ use Behat \Mink \Tests \Helper \Stringer ;
7
7
use Behat \Mink \WebAssert ;
8
8
use PHPUnit \Framework \TestCase ;
9
9
@@ -256,7 +256,7 @@ public function testResponseHeaderContains()
256
256
)
257
257
));
258
258
259
- $ this ->assertCorrectAssertion ('responseHeaderContains ' , array ('foo ' , new Stringer ( 'ba ' ) ));
259
+ $ this ->assertCorrectAssertion ('responseHeaderContains ' , array ('foo ' , 'ba ' ));
260
260
$ this ->assertWrongAssertion (
261
261
'responseHeaderContains ' ,
262
262
array ('bar ' , 'bz ' ),
@@ -277,6 +277,50 @@ public function testResponseHeaderNotContains()
277
277
)
278
278
));
279
279
280
+ $ this ->assertCorrectAssertion ('responseHeaderNotContains ' , array ('foo ' , 'bz ' ));
281
+ $ this ->assertWrongAssertion (
282
+ 'responseHeaderNotContains ' ,
283
+ array ('bar ' , 'ba ' ),
284
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
285
+ 'The text "ba" was found in the "bar" response header, but it should not. '
286
+ );
287
+ }
288
+
289
+ public function testResponseHeaderContainsObjectWithToString ()
290
+ {
291
+ $ this ->session
292
+ ->expects ($ this ->any ())
293
+ ->method ('getResponseHeader ' )
294
+ ->will ($ this ->returnValueMap (
295
+ array (
296
+ array ('foo ' , 'bar ' ),
297
+ array ('bar ' , 'baz ' ),
298
+ )
299
+ ));
300
+
301
+ $ this ->assertCorrectAssertion ('responseHeaderContains ' , array ('foo ' , new Stringer ('ba ' )));
302
+ $ this ->assertWrongAssertion (
303
+ 'responseHeaderContains ' ,
304
+ array ('bar ' , 'bz ' ),
305
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
306
+ 'The text "bz" was not found anywhere in the "bar" response header. '
307
+ );
308
+ }
309
+
310
+ public function testResponseHeaderNotContainsObjectWithToString ()
311
+ {
312
+ $ this ->session
313
+ ->expects ($ this ->any ())
314
+ ->method ('getResponseHeader ' )
315
+ ->will (
316
+ $ this ->returnValueMap (
317
+ array (
318
+ array ('foo ' , 'bar ' ),
319
+ array ('bar ' , 'baz ' ),
320
+ )
321
+ )
322
+ );
323
+
280
324
$ this ->assertCorrectAssertion ('responseHeaderNotContains ' , array ('foo ' , new Stringer ('bz ' )));
281
325
$ this ->assertWrongAssertion (
282
326
'responseHeaderNotContains ' ,
@@ -459,7 +503,7 @@ public function testResponseContains()
459
503
->will ($ this ->returnValue ('Some page text ' ))
460
504
;
461
505
462
- $ this ->assertCorrectAssertion ('responseContains ' , array (new Stringer ( 'PAGE text ' ) ));
506
+ $ this ->assertCorrectAssertion ('responseContains ' , array ('PAGE text ' ));
463
507
$ this ->assertWrongAssertion (
464
508
'responseContains ' ,
465
509
array ('html text ' ),
@@ -487,6 +531,62 @@ public function testResponseNotContains()
487
531
->will ($ this ->returnValue ('Some html text ' ))
488
532
;
489
533
534
+ $ this ->assertCorrectAssertion ('responseNotContains ' , array ('PAGE text ' ));
535
+ $ this ->assertWrongAssertion (
536
+ 'responseNotContains ' ,
537
+ array ('HTML text ' ),
538
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
539
+ 'The string "HTML text" appears in the HTML response of this page, but it should not. '
540
+ );
541
+ }
542
+
543
+ public function testResponseContainsObjectWithToString ()
544
+ {
545
+ $ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
546
+ ->disableOriginalConstructor ()
547
+ ->getMock ()
548
+ ;
549
+
550
+ $ this ->session
551
+ ->expects ($ this ->exactly (2 ))
552
+ ->method ('getPage ' )
553
+ ->will ($ this ->returnValue ($ page ))
554
+ ;
555
+
556
+ $ page
557
+ ->expects ($ this ->exactly (2 ))
558
+ ->method ('getContent ' )
559
+ ->will ($ this ->returnValue ('Some page text ' ))
560
+ ;
561
+
562
+ $ this ->assertCorrectAssertion ('responseContains ' , array (new Stringer ('PAGE text ' )));
563
+ $ this ->assertWrongAssertion (
564
+ 'responseContains ' ,
565
+ array ('html text ' ),
566
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
567
+ 'The string "html text" was not found anywhere in the HTML response of the current page. '
568
+ );
569
+ }
570
+
571
+ public function testResponseNotContainsObjectWithToString ()
572
+ {
573
+ $ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
574
+ ->disableOriginalConstructor ()
575
+ ->getMock ()
576
+ ;
577
+
578
+ $ this ->session
579
+ ->expects ($ this ->exactly (2 ))
580
+ ->method ('getPage ' )
581
+ ->will ($ this ->returnValue ($ page ))
582
+ ;
583
+
584
+ $ page
585
+ ->expects ($ this ->exactly (2 ))
586
+ ->method ('getContent ' )
587
+ ->will ($ this ->returnValue ('Some html text ' ))
588
+ ;
589
+
490
590
$ this ->assertCorrectAssertion ('responseNotContains ' , array (new Stringer ('PAGE text ' )));
491
591
$ this ->assertWrongAssertion (
492
592
'responseNotContains ' ,
0 commit comments