Skip to content

Commit 3dbad8c

Browse files
authored
Merge pull request #7091 from kenjis/test-add-todo-for-route-placeholder-any
test: add `@TODO` to incorrect `(:any)` usages
2 parents 15f54a7 + 6e97857 commit 3dbad8c

5 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/system/CommonFunctionsTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ public function testRouteTo()
266266
{
267267
// prime the pump
268268
$routes = service('routes');
269+
// @TODO Do not put any placeholder after (:any).
270+
// Because the number of parameters passed to the controller method may change.
269271
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
270272

271273
$this->assertSame('/path/string/to/13', route_to('myController::goto', 'string', 13));
@@ -275,6 +277,8 @@ public function testRouteToInCliWithoutLocaleInRoute()
275277
{
276278
Services::createRequest(new App(), true);
277279
$routes = service('routes');
280+
// @TODO Do not put any placeholder after (:any).
281+
// Because the number of parameters passed to the controller method may change.
278282
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
279283

280284
$this->assertSame('/path/string/to/13', route_to('myController::goto', 'string', 13));
@@ -284,6 +288,8 @@ public function testRouteToInCliWithLocaleInRoute()
284288
{
285289
Services::createRequest(new App(), true);
286290
$routes = service('routes');
291+
// @TODO Do not put any placeholder after (:any).
292+
// Because the number of parameters passed to the controller method may change.
287293
$routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'path-to']);
288294

289295
$this->assertSame(
@@ -296,6 +302,8 @@ public function testRouteToWithUnsupportedLocale()
296302
{
297303
Services::createRequest(new App(), false);
298304
$routes = service('routes');
305+
// @TODO Do not put any placeholder after (:any).
306+
// Because the number of parameters passed to the controller method may change.
299307
$routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'path-to']);
300308

301309
$this->assertSame(

tests/system/Helpers/URLHelper/MiscUrlTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ public function testUrlTo(string $expected, string $input, ...$args)
835835
$_SERVER['HTTP_HOST'] = 'example.com';
836836

837837
$routes = service('routes');
838+
// @TODO Do not put any placeholder after (:any).
839+
// Because the number of parameters passed to the controller method may change.
838840
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'gotoPage']);
839841
$routes->add('route/(:any)/to/(:num)', 'myOtherController::goto/$1/$2');
840842

tests/system/Router/RouteCollectionReverseRouteTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function testReverseRoutingFindsSimpleMatch()
5656
{
5757
$routes = $this->getCollector();
5858

59+
// @TODO Do not put any placeholder after (:any).
60+
// Because the number of parameters passed to the controller method may change.
5961
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
6062

6163
$match = $routes->reverseRoute('myController::goto', 'string', 13);
@@ -67,6 +69,8 @@ public function testReverseRoutingWithLocaleAndFindsSimpleMatch()
6769
{
6870
$routes = $this->getCollector();
6971

72+
// @TODO Do not put any placeholder after (:any).
73+
// Because the number of parameters passed to the controller method may change.
7074
$routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2');
7175

7276
$match = $routes->reverseRoute('myController::goto', 'string', 13);
@@ -78,6 +82,8 @@ public function testReverseRoutingReturnsFalseWithBadParamCount()
7882
{
7983
$routes = $this->getCollector();
8084

85+
// @TODO Do not put any placeholder after (:any).
86+
// Because the number of parameters passed to the controller method may change.
8187
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1');
8288

8389
$this->assertFalse($routes->reverseRoute('myController::goto', 'string', 13));
@@ -87,6 +93,8 @@ public function testReverseRoutingReturnsFalseWithNoMatch()
8793
{
8894
$routes = $this->getCollector();
8995

96+
// @TODO Do not put any placeholder after (:any).
97+
// Because the number of parameters passed to the controller method may change.
9098
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
9199

92100
$this->assertFalse($routes->reverseRoute('myBadController::goto', 'string', 13));
@@ -96,6 +104,8 @@ public function testReverseRoutingThrowsExceptionWithBadParamTypes()
96104
{
97105
$routes = $this->getCollector();
98106

107+
// @TODO Do not put any placeholder after (:any).
108+
// Because the number of parameters passed to the controller method may change.
99109
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
100110

101111
$this->expectException(RouterException::class);

tests/system/Router/RouteCollectionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ public function testNamedRoutesFillInParams()
889889
{
890890
$routes = $this->getCollector();
891891

892+
// @TODO Do not put any placeholder after (:any).
893+
// Because the number of parameters passed to the controller method may change.
892894
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'namedRoute']);
893895

894896
$match = $routes->reverseRoute('namedRoute', 'string', 13);
@@ -900,6 +902,8 @@ public function testNamedRoutesWithLocaleAndFillInParams()
900902
{
901903
$routes = $this->getCollector();
902904

905+
// @TODO Do not put any placeholder after (:any).
906+
// Because the number of parameters passed to the controller method may change.
903907
$routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'namedRoute']);
904908

905909
$match = $routes->reverseRoute('namedRoute', 'string', 13);

tests/system/View/ParserPluginTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public function testRoute()
9696
{
9797
// prime the pump
9898
$routes = service('routes');
99+
// @TODO Do not put any placeholder after (:any).
100+
// Because the number of parameters passed to the controller method may change.
99101
$routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2');
100102

101103
$template = '{+ route myController::goto string 13 +}';

0 commit comments

Comments
 (0)