@@ -16,7 +16,7 @@ public function can_filter_eq()
1616 {
1717 $ filter = new BooleanFilter ;
1818 $ builder = Pet::query ()->getQuery ();
19- $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('eq ' , true ));
19+ $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('eq ' , ' true ' ));
2020
2121 $ this ->assertEquals (
2222 "select * from `pets` where `is_active` = ? " ,
@@ -32,7 +32,7 @@ public function can_filter_neq()
3232 {
3333 $ filter = new BooleanFilter ;
3434 $ builder = Pet::query ()->getQuery ();
35- $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('neq ' , true ));
35+ $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('neq ' , ' true ' ));
3636
3737 $ this ->assertEquals (
3838 "select * from `pets` where `is_active` != ? " ,
@@ -46,10 +46,9 @@ public function can_filter_neq()
4646 */
4747 public function can_override_true_and_false_val ()
4848 {
49-
5049 $ filter = new BooleanFilter ('yes ' , 'no ' );
5150 $ builder = Pet::query ()->getQuery ();
52- $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('eq ' , true ));
51+ $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('eq ' , ' true ' ));
5352
5453 $ this ->assertEquals (
5554 "select * from `pets` where `is_active` = ? " ,
@@ -58,6 +57,22 @@ public function can_override_true_and_false_val()
5857 $ this ->assertEquals (['yes ' ], $ builder ->getBindings ());
5958 }
6059
60+ /**
61+ * @test
62+ */
63+ public function can_handle_false_in_url_string_as_boolean ()
64+ {
65+ $ filter = new BooleanFilter ;
66+ $ builder = Pet::query ()->getQuery ();
67+ $ filter ->modifyQuery ($ builder , $ this ->searchTerm ('eq ' , 'false ' ));
68+
69+ $ this ->assertEquals (
70+ "select * from `pets` where `is_active` = ? " ,
71+ $ builder ->toSql ()
72+ );
73+ $ this ->assertEquals ([0 ], $ builder ->getBindings ());
74+ }
75+
6176 private function searchTerm ($ operator , $ term )
6277 {
6378 return new SearchTerm ('is_active ' , $ operator , 'is_active ' , $ term );
0 commit comments