title: How can I mock a laravel controller method to check if it received a call to a specific method with appropriate parameters
body: <p>I am using laravel 5.4 and have a route in my api.php file like below: </p>
  
  <p><code>Route::middleware('auth:api')-&gt;post('/message', 'MessagesController@store');
  </code></p>
  
  <p>So initially lets just say I wanted to check that when I make a post call to 'api/message' the store() method is suppose to be called. </p>
  
  <p>Below is my test code that I tried:</p>
  
  <pre><code>$mock = \Mockery::mock(MessagesController::class);
  $mock-&gt;shouldReceive('store')-&gt;once();
  $this-&gt;app-&gt;instance(MessagesController::class, $mock);
  
  $response = $this-&gt;call('POST','api/message',[
          'receiver_id' =&gt; $receiver-&gt;id,
          'message' =&gt; 'Testing OneSignal - unit test'
      ]);
  \Mockery::close();
  </code></pre>
  
  <p>When I run the test I get the following error in terminal:</p>
  
  <p><code>1)Tests\Feature\NotificationTest::a_onesignal_notification_is_sent_when_a_new_message_is_sent
      Mockery\Exception\InvalidCountException: Method store() from 
      Mockery_1_App_Http_Controllers_MessagesController should be called
      exactly 1 times but called 0 times.</code></p>
  
  <p>My intention is not really trying to check if store() method is being called, which I know I have other ways to go around. Within the store method I delegate a method to one of the traits which in returns makes a curl call, I would like to test if that method is receiving the intended paramaters.</p>
  
  <p>Thanks in advance for the help.</p>