UserManager에 따라 컨트롤러가 있습니다. 이것은 컨트롤러 생성자입니다.
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
메서드 에 대한 기대치를 설정 했는데 존재하지 않으므로 어디에서나 호출되지 않지만 테스트는 실패하지 않습니다.
왜?
foo
메서드를 호출해야하는 횟수를 지정 해야합니다.
->shouldReceive('foo')->once();
tearDown
Mockery를 재설정 하는 방법 이 있는지 확인하십시오 . 그렇지 않으면 작동하지 않습니다.
public function tearDown()
{
Mockery::close();
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다