Skip to content

Commit 9ddf033

Browse files
committed
minor #42299 [Routing] Add test for non-callable arrays as controllers (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [Routing] Add test for non-callable arrays as controllers | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A I've backported the test and doc block change from #42298. Commits ------- a1eb24bef2 Add test for non-callable arrays as controllers
2 parents 939571d + d67a6d9 commit 9ddf033

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ final public function methods(array $methods): self
126126
/**
127127
* Adds the "_controller" entry to defaults.
128128
*
129-
* @param callable|string $controller a callable or parseable pseudo-callable
129+
* @param callable|string|array $controller a callable or parseable pseudo-callable
130130
*
131131
* @return $this
132132
*/

Tests/Fixtures/php_dsl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
->condition('abc')
1010
->options(['utf8' => true])
1111
->add('buz', 'zub')
12-
->controller('foo:act');
12+
->controller('foo:act')
13+
->add('controller_class', '/controller')
14+
->controller(['Acme\MyApp\MyController', 'myAction']);
1315

1416
$routes->import('php_dsl_sub.php')
1517
->prefix('/sub')

Tests/Fixtures/php_object_dsl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ public function __invoke(RoutingConfigurator $routes)
1111
->condition('abc')
1212
->options(['utf8' => true])
1313
->add('buz', 'zub')
14-
->controller('foo:act');
14+
->controller('foo:act')
15+
->add('controller_class', '/controller')
16+
->controller(['Acme\MyApp\MyController', 'myAction']);
1517

1618
$routes->import('php_dsl_sub.php')
1719
->prefix('/sub')

Tests/Loader/PhpFileLoaderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ public function testRoutingConfigurator()
174174
$expectedCollection->add('buz', (new Route('/zub'))
175175
->setDefaults(['_controller' => 'foo:act'])
176176
);
177+
$expectedCollection->add('controller_class', (new Route('/controller'))
178+
->setDefaults(['_controller' => ['Acme\MyApp\MyController', 'myAction']])
179+
);
177180
$expectedCollection->add('c_root', (new Route('/sub/pub/'))
178181
->setRequirements(['id' => '\d+'])
179182
);

0 commit comments

Comments
 (0)