File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 99use Illuminate \Http \Request ;
1010use Illuminate \Routing \Router ;
1111use Mockery as m ;
12+ use PHPUnit \Framework \Attributes \DataProvider ;
1213use PHPUnit \Framework \TestCase ;
1314use Stringable ;
1415
@@ -127,9 +128,10 @@ public function __toString()
127128 $ this ->assertSame (['one ' , 'two ' ], $ this ->getRoute ()->middleware ());
128129 }
129130
130- public function testMiddlewareAsNull ()
131+ #[DataProvider('falsyMiddlewareValues ' )]
132+ public function testFalsyMiddlewareValuesAreIgnored ($ middleware )
131133 {
132- $ this ->router ->middleware (null )->get ('users ' , function () {
134+ $ this ->router ->middleware ($ middleware )->get ('users ' , function () {
133135 return 'all-users ' ;
134136 });
135137
@@ -138,12 +140,21 @@ public function testMiddlewareAsNull()
138140
139141 $ this ->router ->get ('users ' , function () {
140142 return 'all-users ' ;
141- })->middleware (null );
143+ })->middleware ($ middleware );
142144
143145 $ this ->seeResponse ('all-users ' , Request::create ('users ' , 'GET ' ));
144146 $ this ->assertSame ([], $ this ->getRoute ()->middleware ());
145147 }
146148
149+ public static function falsyMiddlewareValues (): iterable
150+ {
151+ yield [null ];
152+ yield [false ];
153+ yield ['' ];
154+ yield [0 ];
155+ yield [0.0 ];
156+ }
157+
147158 public function testWithoutMiddlewareRegistration ()
148159 {
149160 $ this ->router ->middleware (['one ' , 'two ' ])->get ('users ' , function () {
You can’t perform that action at this time.
0 commit comments