unit testing - Mockery cannot create a partial mock with Eloquent Model fill method -


i'm trying test laravel api. when try create partial mock eloquent model fill method, phpunit throws error.

code

$mock = m::mock('app\user', [])->makepartial(); $mock->shouldreceive('fill')->once()->andreturn('ok'); $result = $mock->fill([]); var_dump($result); 

error

php fatal error:  call member function __call() on non-object php fatal error:  uncaught exception 'illuminate\contracts\container\bindingresolutionexception' message 'target [illuminate\contracts\debug\exceptionhandler] not instantiable. 

i don't know if either eloquent bug, or mockery error.

notes:

i temporarily solved problem using model::update method instead of model::fill , model::save, still want know how mock fill method.

links

http://laravel.com/api/5.0/illuminate/database/eloquent/model.html#method_fill

i think mock object created without method. need define expectation fill() method dictate mocked behaviour. like:

$mock->shouldreceive('fill')->once()->andreturn('ok'); 

hope helps.


Comments