【发布时间】:2017-04-10 21:23:02
【问题描述】:
我正在使用 PHPUnit 来测试我的应用程序,在这种情况下,我正在测试一个 API 调用(我正在通过它执行 GET、POST、PUT 和 DELETE)。 index 方法响应 GET(/api) 路由,在这个方法中我有一个自定义请求:
public function index(\Api\User\Requests\IndexRequest $request)
{
// do some stuff...
}
Api\User\Requests\IndexRequest 类如下所示:
class Request extends IndexApiRequest
{
// some methods in here
}
当我通过 PHPUnit 执行测试时,它会提示:
Class Api\User\Requests\IndexRequest does not exist
检查它在 Illuminate\Routing\RouteDependencyResolverTrait 中死亡的跟踪路由。我不知道如何干预执行,因为它似乎发生在 PHPUnit 和 Laravel 之间。
有人有想法吗?我正在使用在 Ubuntu 16.04、PHP 7.0 和 nginx 上运行的 Laravel 5.3、PHPUnit 5.6.5。
谢谢!
【问题讨论】:
标签: php dependency-injection phpunit laravel-5.3