Testing Laravel View Composers with Mockery
0 I am trying to test my View Composers. Whenever I pass an object to the $view->with('string', $object) , my test fails. This is when I do the test like this: $view ->shouldReceive('with') ->with('favorites', $this->user->favorites(Ad::class)->get()) ->once(); I'm pretty sure this is due to strict checking. So I looked around and saw this issue. However, I can't seem to get it working. The closure return true, but the test fails: MockeryExceptionInvalidCountException : Method with('favorites', < Closure===true >) from Mockery_3_Illuminate_View_View should be called exactly 1 times but called 0 times. Here is my current test public function it_passes_favorites_to_the_view() $this->setUpUser(); // basically sets $this->user to a User object Auth::shouldReceive('user') ->once() ->andReturn($this->user); $composer = new FavoritesComposer(); $view = Mockery::spy(View::class); ...