1
我有一个Controller,具体取决于UserManager。这是控制器的构造函数:Laravel 5.1测试控制器时忽略嘲笑期望
public function __construct(UserManager $manager) {
$this->manager = $manager;
}
这是测试代码。
public function test_something() {
$this->withoutMiddleware();
// Setup Input.
$user = ['email' => '[email protected]', 'password' => 'pass', 'accessLevel' => 'admin'];
// Setup expectations.
$mock = \Mockery::mock("Users\UserManager")->shouldReceive('foo');
// Bind to container... not sure whether this is needed.
$this->app->instance("Users\UserManager", $mock);
// Call action.
$this->call('POST', 'api/v1/temp/users', ['user' => $user]);
}
我设置的foo
方法,它不存在,因此不被任何调用的期望,但我的测试不会失败。
为什么?
哎呦错过了!谢谢你,小伙伴。 – brazorf