-
-
Notifications
You must be signed in to change notification settings - Fork 554
Closed
Milestone
Description
Problem/Motivation
-
generate:controller
results in error and creation of controller file at/
. -
Drupal version: 8.6.7.
-
Console version: 1.8.0.
How to reproduce
From docroot:
../vendor/drupal/console/bin/drupal generate:controller \
--module="unify_event" \
--class="MyController" \
--routes='"title":"ControllerMethod", "name":"unify_event.view_events", "method":"view_event", "path":"/events/{name}"' \
--test
[ERROR] <em class="placeholder">Warning</em>: call_user_func_array() expects parameter 1 to be a valid callback,
class 'SplFileInfo' does not have a method 'getTestPath' in Drupal\Core\Extension\Extension->__call() (line 155 of core/lib/Drupal/Core/Extension/Extension.php). Drupal\Core\Extension\Extension->__call('getTestPath', Array) (Line: 57)
Drupal\Console\Generator\ControllerGenerator->generate(Array) (Line: 156)
Drupal\Console\Command\Generate\ControllerCommand->execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command->run(Object, Object) (Line: 971)
Symfony\Component\Console\Application->doRunCommand(Object, Object, Object) (Line: 248)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 185)
Drupal\Console\Core\Application->doRun(Object, Object) (Line: 64)
Drupal\Console\Application->doRun(Object, Object) (Line: 148)
Symfony\Component\Console\Application->run() (Line: 89)
require('[...]/vendor/drupal/console/bin/drupal.php') (Line: 4)
Notes:
- Error occurs regardless whether module is enabled or disabled.
- File
MyControllerTest.php
is created at/
due to missing path expected fromgetTestPath()
. drupal/console/src/extension/Manager->getTestPath()
is never called.drupal/console/src/extension/Manager->getModule() <- createExtension()
is called.
In ControllerGenerator.php
(erroneously calls \Drupal\Console\Extension\Extension->getTestPath()
):
...
if ($test) {
$this->renderFile(
'module/Tests/Controller/controller.php.twig',
**$moduleInstance->getTestPath('Controller')** . '/' . $class . 'Test.php',
$parameters
);
}
...
The `Manager->getTestPath()' takes the `testType` argument:
public function getTestPath($testType, $fullPath = false)
{
return $this->getPath($fullPath) . '/Tests/' . $testType;
}
Aside: Function `$this->getPath()` is not in the `Manager` class, but the class is in the `Extension` namespace.
A `\Drupal\Console\Extension\Extension->getTest**s**Path()` function exists, but doesn't have a `testType` argument.
### Temporary Solution
`sudo mv /MyControllerTest.php docroot/modules/unify_event/tests/Controller/`
### Solution
Move the `Manager->getTestPath()` `testType' argument over to `Extension->getTestsPath()` and correct `getTestPath` to `getTestsPath` in `ControllerGenerator`.
Note: This needs testing.
Metadata
Metadata
Assignees
Labels
No labels