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