@@ -292,6 +292,12 @@ public function testHostMethod()
292
292
293
293
$ request = Request::create ('https://example.com ' );
294
294
$ this ->assertSame ('example.com ' , $ request ->host ());
295
+
296
+ $ request = Request::create ('https://example.com:8080 ' );
297
+ $ this ->assertSame ('example.com ' , $ request ->host ());
298
+
299
+ $ request = Request::create ('http://example.com:8080 ' );
300
+ $ this ->assertSame ('example.com ' , $ request ->host ());
295
301
}
296
302
297
303
public function testHttpHostMethod ()
@@ -336,6 +342,7 @@ public function testHasMethod()
336
342
$ request = Request::create ('/ ' , 'GET ' , ['name ' => 'Taylor ' , 'email ' => 'foo ' ]);
337
343
$ this ->assertTrue ($ request ->has ('name ' ));
338
344
$ this ->assertTrue ($ request ->has ('name ' , 'email ' ));
345
+ $ this ->assertTrue ($ request ->has (['name ' , 'email ' ]));
339
346
340
347
$ request = Request::create ('/ ' , 'GET ' , ['foo ' => ['bar ' , 'bar ' ]]);
341
348
$ this ->assertTrue ($ request ->has ('foo ' ));
@@ -427,6 +434,7 @@ public function testMissingMethod()
427
434
$ this ->assertFalse ($ request ->missing ('city ' ));
428
435
$ this ->assertTrue ($ request ->missing ('foo ' ));
429
436
$ this ->assertTrue ($ request ->missing ('name ' , 'email ' ));
437
+ $ this ->assertTrue ($ request ->missing (['name ' , 'email ' ]));
430
438
431
439
$ request = Request::create ('/ ' , 'GET ' , ['name ' => 'Taylor ' , 'email ' => 'foo ' ]);
432
440
$ this ->assertFalse ($ request ->missing ('name ' ));
@@ -478,6 +486,7 @@ public function testFilledMethod()
478
486
$ request = Request::create ('/ ' , 'GET ' , ['name ' => 'Taylor ' , 'email ' => 'foo ' ]);
479
487
$ this ->assertTrue ($ request ->filled ('name ' ));
480
488
$ this ->assertTrue ($ request ->filled ('name ' , 'email ' ));
489
+ $ this ->assertTrue ($ request ->filled (['name ' , 'email ' ]));
481
490
482
491
// test arrays within query string
483
492
$ request = Request::create ('/ ' , 'GET ' , ['foo ' => ['bar ' , 'baz ' ]]);
@@ -523,10 +532,10 @@ public function testFilledAnyMethod()
523
532
$ this ->assertTrue ($ request ->anyFilled (['foo ' , 'name ' ]));
524
533
$ this ->assertTrue ($ request ->anyFilled ('foo ' , 'name ' ));
525
534
526
- $ this ->assertFalse ($ request ->anyFilled ('age ' , 'city ' ));
535
+ $ this ->assertFalse ($ request ->anyFilled ([ 'age ' , 'city ' ] ));
527
536
$ this ->assertFalse ($ request ->anyFilled ('age ' , 'city ' ));
528
537
529
- $ this ->assertFalse ($ request ->anyFilled ('foo ' , 'bar ' ));
538
+ $ this ->assertFalse ($ request ->anyFilled ([ 'foo ' , 'bar ' ] ));
530
539
$ this ->assertFalse ($ request ->anyFilled ('foo ' , 'bar ' ));
531
540
}
532
541
@@ -543,12 +552,14 @@ public function testInputMethod()
543
552
544
553
public function testBooleanMethod ()
545
554
{
546
- $ request = Request::create ('/ ' , 'GET ' , ['with_trashed ' => 'false ' , 'download ' => true , 'checked ' => 1 , 'unchecked ' => '0 ' ]);
555
+ $ request = Request::create ('/ ' , 'GET ' , ['with_trashed ' => 'false ' , 'download ' => true , 'checked ' => 1 , 'unchecked ' => '0 ' , ' with_on ' => ' on ' , ' with_yes ' => ' yes ' ]);
547
556
$ this ->assertTrue ($ request ->boolean ('checked ' ));
548
557
$ this ->assertTrue ($ request ->boolean ('download ' ));
549
558
$ this ->assertFalse ($ request ->boolean ('unchecked ' ));
550
559
$ this ->assertFalse ($ request ->boolean ('with_trashed ' ));
551
560
$ this ->assertFalse ($ request ->boolean ('some_undefined_key ' ));
561
+ $ this ->assertTrue ($ request ->boolean ('with_on ' ));
562
+ $ this ->assertTrue ($ request ->boolean ('with_yes ' ));
552
563
}
553
564
554
565
public function testCollectMethod ()
@@ -739,12 +750,15 @@ public function testExceptMethod()
739
750
$ request = Request::create ('/ ' , 'GET ' , ['name ' => 'Taylor ' , 'age ' => 25 ]);
740
751
$ this ->assertEquals (['name ' => 'Taylor ' ], $ request ->except ('age ' ));
741
752
$ this ->assertEquals ([], $ request ->except ('age ' , 'name ' ));
753
+ $ this ->assertEquals ([], $ request ->except (['age ' , 'name ' ]));
742
754
}
743
755
744
756
public function testQueryMethod ()
745
757
{
746
758
$ request = Request::create ('/ ' , 'GET ' , ['name ' => 'Taylor ' ]);
759
+ $ this ->assertSame (['name ' => 'Taylor ' ], $ request ->query ());
747
760
$ this ->assertSame ('Taylor ' , $ request ->query ('name ' ));
761
+ $ this ->assertSame ('Taylor ' , $ request ->query ('name ' , 'Amir ' ));
748
762
$ this ->assertSame ('Bob ' , $ request ->query ('foo ' , 'Bob ' ));
749
763
$ all = $ request ->query (null );
750
764
$ this ->assertSame ('Taylor ' , $ all ['name ' ]);
@@ -761,7 +775,9 @@ public function testQueryMethod()
761
775
public function testPostMethod ()
762
776
{
763
777
$ request = Request::create ('/ ' , 'POST ' , ['name ' => 'Taylor ' ]);
778
+ $ this ->assertSame (['name ' => 'Taylor ' ], $ request ->post ());
764
779
$ this ->assertSame ('Taylor ' , $ request ->post ('name ' ));
780
+ $ this ->assertSame ('Taylor ' , $ request ->post ('name ' , 'Amir ' ));
765
781
$ this ->assertSame ('Bob ' , $ request ->post ('foo ' , 'Bob ' ));
766
782
$ all = $ request ->post (null );
767
783
$ this ->assertSame ('Taylor ' , $ all ['name ' ]);
@@ -770,7 +786,9 @@ public function testPostMethod()
770
786
public function testCookieMethod ()
771
787
{
772
788
$ request = Request::create ('/ ' , 'GET ' , [], ['name ' => 'Taylor ' ]);
789
+ $ this ->assertSame (['name ' => 'Taylor ' ], $ request ->cookie ());
773
790
$ this ->assertSame ('Taylor ' , $ request ->cookie ('name ' ));
791
+ $ this ->assertSame ('Taylor ' , $ request ->cookie ('name ' , 'Amir ' ));
774
792
$ this ->assertSame ('Bob ' , $ request ->cookie ('foo ' , 'Bob ' ));
775
793
$ all = $ request ->cookie (null );
776
794
$ this ->assertSame ('Taylor ' , $ all ['name ' ]);
@@ -814,6 +832,7 @@ public function testHasFileMethod()
814
832
];
815
833
$ request = Request::create ('/ ' , 'GET ' , [], [], $ files );
816
834
$ this ->assertTrue ($ request ->hasFile ('foo ' ));
835
+ $ this ->assertFalse ($ request ->hasFile ('bar ' ));
817
836
}
818
837
819
838
public function testServerMethod ()
@@ -869,6 +888,7 @@ public function testHeaderMethod()
869
888
{
870
889
$ request = Request::create ('/ ' , 'GET ' , [], [], [], ['HTTP_DO_THIS ' => 'foo ' ]);
871
890
$ this ->assertSame ('foo ' , $ request ->header ('do-this ' ));
891
+ $ this ->assertSame ('default ' , $ request ->header ('do-that ' , 'default ' ));
872
892
$ all = $ request ->header (null );
873
893
$ this ->assertSame ('foo ' , $ all ['do-this ' ][0 ]);
874
894
}
@@ -883,13 +903,18 @@ public function testBearerTokenMethod()
883
903
884
904
$ request = Request::create ('/ ' , 'GET ' , [], [], [], ['HTTP_AUTHORIZATION ' => 'Bearer foo,bar ' ]);
885
905
$ this ->assertSame ('foo ' , $ request ->bearerToken ());
906
+
907
+ $ request = Request::create ('/ ' , 'GET ' , [], [], [], ['HTTP_AUTHORIZATION ' => 'foo,bar ' ]);
908
+ $ this ->assertNull ($ request ->bearerToken ());
886
909
}
887
910
888
911
public function testJSONMethod ()
889
912
{
890
913
$ payload = ['name ' => 'taylor ' ];
891
914
$ request = Request::create ('/ ' , 'GET ' , [], [], [], ['CONTENT_TYPE ' => 'application/json ' ], json_encode ($ payload ));
892
915
$ this ->assertSame ('taylor ' , $ request ->json ('name ' ));
916
+ $ this ->assertSame ('taylor ' , $ request ->json ('name ' , 'Otwell ' ));
917
+ $ this ->assertSame ('Moharami ' , $ request ->json ('family ' , 'Moharami ' ));
893
918
$ this ->assertSame ('taylor ' , $ request ->input ('name ' ));
894
919
$ data = $ request ->json ()->all ();
895
920
$ this ->assertEquals ($ payload , $ data );
0 commit comments