@@ -1035,24 +1035,59 @@ public function testRoutePlaceholderAnyWithMultipleSegmentsParamTrue(): void
10351035 $ this ->assertSame (['123/456 ' ], $ router ->params ());
10361036 }
10371037
1038- public function testMultipleSegmentsParamTrueWithTenPlaceholders (): void
1039- {
1038+ /**
1039+ * @param list<string> $expectedParams
1040+ */
1041+ #[DataProvider('provideMultipleSegmentsParamTruePlaceholders ' )]
1042+ public function testMultipleSegmentsParamTrueWithManyPlaceholders (
1043+ string $ route ,
1044+ string $ handler ,
1045+ string $ uri ,
1046+ array $ expectedParams ,
1047+ ): void {
10401048 $ routingConfig = new Routing ();
10411049 $ routingConfig ->multipleSegmentsOneParam = true ;
10421050 Factories ::injectMock ('config ' , Routing::class, $ routingConfig );
10431051
10441052 $ this ->createRouteCollection ($ routingConfig );
1045- $ this ->collection ->get (
1046- '(:segment)/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)/(:segment) ' ,
1047- 'Catalog::lookup/$1/$2/$3/$4/$5/$6/$7/$8/$9/$10 ' ,
1048- );
1053+ $ this ->collection ->get ($ route , $ handler );
10491054 $ router = new Router ($ this ->collection , $ this ->request );
10501055
1051- $ router ->handle (' a/b/c/d/e/f/g/h/i/j ' );
1056+ $ router ->handle ($ uri );
10521057
10531058 $ this ->assertSame ('\Catalog ' , $ router ->controllerName ());
10541059 $ this ->assertSame ('lookup ' , $ router ->methodName ());
1055- $ this ->assertSame (['a ' , 'b ' , 'c ' , 'd ' , 'e ' , 'f ' , 'g ' , 'h ' , 'i ' , 'j ' ], $ router ->params ());
1060+ $ this ->assertSame ($ expectedParams , $ router ->params ());
1061+ }
1062+
1063+ /**
1064+ * @return iterable<string, array{string, string, string, list<string>}>
1065+ */
1066+ public static function provideMultipleSegmentsParamTruePlaceholders (): iterable
1067+ {
1068+ $ nineSegments = implode ('/ ' , array_fill (0 , 9 , '(:segment) ' ));
1069+ $ tenSegments = implode ('/ ' , array_fill (0 , 10 , '(:segment) ' ));
1070+
1071+ yield 'nine placeholders (boundary) ' => [
1072+ $ nineSegments ,
1073+ 'Catalog::lookup/$1/$2/$3/$4/$5/$6/$7/$8/$9 ' ,
1074+ 'a/b/c/d/e/f/g/h/i ' ,
1075+ ['a ' , 'b ' , 'c ' , 'd ' , 'e ' , 'f ' , 'g ' , 'h ' , 'i ' ],
1076+ ];
1077+
1078+ yield 'ten placeholders ' => [
1079+ $ tenSegments ,
1080+ 'Catalog::lookup/$1/$2/$3/$4/$5/$6/$7/$8/$9/$10 ' ,
1081+ 'a/b/c/d/e/f/g/h/i/j ' ,
1082+ ['a ' , 'b ' , 'c ' , 'd ' , 'e ' , 'f ' , 'g ' , 'h ' , 'i ' , 'j ' ],
1083+ ];
1084+
1085+ yield 'out-of-range reference resolves to empty string ' => [
1086+ $ tenSegments ,
1087+ 'Catalog::lookup/$1/$2/$3/$4/$5/$6/$7/$8/$9/$10/$11 ' ,
1088+ 'a/b/c/d/e/f/g/h/i/j ' ,
1089+ ['a ' , 'b ' , 'c ' , 'd ' , 'e ' , 'f ' , 'g ' , 'h ' , 'i ' , 'j ' , '' ],
1090+ ];
10561091 }
10571092
10581093 public function testLogsRouteAttributeInstantiationFailureWithContext (): void
0 commit comments