@@ -549,18 +549,34 @@ public static function rangeDataProvider(): array {
549549 [7 , 14 , 5 , true ],
550550 [7 , 14 , 10 , false ],
551551 [-14 , -7 , -10 , false ],
552+ [null , null , -1 , false ],
553+
554+ // $limit comes with default limits of self::DEFAULT_MIN (1) <= $limit <= self::DEFAULT_MAX (500)
555+ [null , null , -1 , true , 'limit ' ],
556+ [null , null , -1 , false , 'limit ' , -1 ],
557+ [null , null , 0 , true , 'limit ' ],
558+ [null , null , 0 , true , 'limit ' , -1 ],
559+ [null , null , 1 , false , 'limit ' ],
560+ [null , null , 500 , false , 'limit ' ],
561+ [null , null , 501 , true , 'limit ' ],
552562 ];
553563 }
554564
555565 #[\PHPUnit \Framework \Attributes \DataProvider('rangeDataProvider ' )]
556- public function testEnsureParameterValueSatisfiesRange (int $ min , int $ max , int $ input , bool $ throw ): void {
566+ public function testEnsureParameterValueSatisfiesRange (? int $ min , ? int $ max , int $ input , bool $ throw, string $ param = ' myArgument ' , ? int $ default = null ): void {
557567 $ this ->reflector = $ this ->createMock (ControllerMethodReflector::class);
558- $ this ->reflector ->expects ($ this ->any ())
559- ->method ('getRange ' )
560- ->willReturn ([
561- 'min ' => $ min ,
562- 'max ' => $ max ,
563- ]);
568+ if ($ min === null && $ max === null ) {
569+ $ this ->reflector ->expects ($ this ->any ())
570+ ->method ('getRange ' )
571+ ->willReturn (null );
572+ } else {
573+ $ this ->reflector ->expects ($ this ->any ())
574+ ->method ('getRange ' )
575+ ->willReturn ([
576+ 'min ' => $ min ,
577+ 'max ' => $ max ,
578+ ]);
579+ }
564580
565581 $ this ->dispatcher = new Dispatcher (
566582 $ this ->http ,
@@ -578,7 +594,7 @@ public function testEnsureParameterValueSatisfiesRange(int $min, int $max, int $
578594 $ this ->expectException (ParameterOutOfRangeException::class);
579595 }
580596
581- $ this -> invokePrivate ($ this ->dispatcher , 'ensureParameterValueSatisfiesRange ' , [' myArgument ' , $ input ]);
597+ self :: invokePrivate ($ this ->dispatcher , 'ensureParameterValueSatisfiesRange ' , [$ param , $ input, $ default ]);
582598 if (!$ throw ) {
583599 // do not mark this test risky
584600 $ this ->assertTrue (true );
0 commit comments