2014-01-14 5 views
3

우선 나는이Laravel Facade에 Partial Mockup을 지정하려면 어떻게해야합니까? 그래서 나는 아직 내가 외관에 직접 시도 조롱을 구현하는 Laravel 외관을 발견

$mock = m::mock('Cartalyst\Sentry\Facades\Laravel\Sentry'); 
$mock->shouldReceive('getUser')->once()->andReturn($userInst); 

을 시도하지만 나에게

Fatal error: Cannot redeclare Mockery_1964315998_Cartalyst_Sentry_Facades_Laravel_Sentry::shouldReceive() 

했다.
Sentry::shouldReceive('getUser')->once()->andReturn($userInst); 

그러나 이제 문제는 내가 여기에 부분적인 모형의 동작을 필요로하지만 난 그것을 알 수 있습니까 표시되지 않습니다 본질적으로 객체 것이 다른 기능을 찾지 못하는 것입니다.
BadMethodCallException: Method Mockery_2115409749_Cartalyst_Sentry_Sentry::check() does not exist on this mock object 

는) 당신이 센트리 :::: getFacadeRoot를 (추가 할 수 있습니다

A traditional partial mock defined ahead of time which methods of a class are to be mocked and which are to left unmocked (i.e. callable as normal). The syntax for creating traditional mocks is: 

$mock = \Mockery::mock('MyClass[foo,bar]'); 
In the above example, the foo() and bar() methods of MyClass will be mocked but no other MyClass methods are touched. You will need to define expectations for the foo() and bar() methods to dictate their mocked behaviour. 

답변

4

필요 무엇인가 -> makePartial(); 뒤에 Sentry :: shouldReceive ('getUser') -> once() -> andReturn ($ userInst);