You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem here is that $this->currentRequest->route() returns null since the $routeResolver is null and so the $controller stays set to null and HtmlDumper just doesn't like it.
I've solved my issue by adding this to the RequestContextProvider
/** * Get the context. * * @return array|null */publicfunctiongetContext(): ?array
{
if ($this->currentRequest === null) {
returnnull;
}
$controller = null;
if ($route = $this->currentRequest->route()) {
$controller = $route->controller;
if (! $controller && ! is_string($route->action['uses'])) {
$controller = $route->action['uses'];
}
}
if (app()->runningUnitTests()) {
$controller = $this->guessPHPUnitTestController($this->currentRequest->server->get('argv'));
}
return [
'uri' => $this->currentRequest->getUri(),
'method' => $this->currentRequest->getMethod(),
'controller' => $controller ? $this->cloner->cloneVar(class_basename($controller)) : $controller,
'identifier' => spl_object_hash($this->currentRequest),
];
}
/** * Try to provide as much information to the dump as possible * * @param array $args * * @return string */privatefunctionguessPHPUnitTestController(array$args)
{
$controller = TestCase::class;
var_export($args);
if (false === in_array('--filter', $args)) {
return$controller;
}
if (preg_match('/^[A-Z][a-zA-Z]+Test$/', $args[2])) {
return$args[2];
}
if (preg_match('/^test[A-Z][0-9a-zA-Z]+/', $args[2])) {
return$controller . '::' . $args[2];
}
return$controller;
}
which produces
If this way is okay for you, I can create PR with this solution :)
The text was updated successfully, but these errors were encountered:
Simillar to #9 (I guess?) I'm getting an exception while running unit test and try to debug a request with the
->dump()
helper, such asThe problem here is that
$this->currentRequest->route()
returnsnull
since the$routeResolver
isnull
and so the$controller
stays set tonull
andHtmlDumper
just doesn't like it.I've solved my issue by adding this to the
RequestContextProvider
which produces
If this way is okay for you, I can create PR with this solution :)
The text was updated successfully, but these errors were encountered: