jeudi 1 octobre 2015

Mock more then one interface Laravel 5

I am trying to mock more then one interface but don't work... Here is my code:

$user = new User(array('name' => 'John','id'=>1));
$this->be($user);
$mock = m::mock('App\Repositories\CommentInterface');
$mock->shouldReceive('getCommentForAuth')->once()->andReturn(true);
App::instance('App\Repositories\CommentInterface', $mock);

$mock1 = m::mock('App\Repositories\UserAuthInterface');
$mock1->shouldReceive('getUserId')->once()->andReturn(1);
App::instance('App\Repositories\UserAuthInterface', $mock1);

$response = $this->call('PUT', '/api/project/1/comment/1/comments/1', array(
    'text' => 'aaaaavvvvvvvvvvvvvvvvvvvvvvvv',
    'projectID' => 1,
    'id'    => 1,
    'level' => 1
));
dd($response);
$this->assertResponseStatus(200);

If I remove this part :

$mock1 = m::mock('App\Repositories\UserAuthInterface');
$mock1->shouldReceive('getUserId')->once()->andReturn(1);
App::instance('App\Repositories\UserAuthInterface', $mock1);

All works fine... Anyone know what im doing wrong?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QMKZdn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire