title: Mocking a method call in a route controller in Lumen for testing
body: <p>I have the following controller class in my Lumen application that implements the route controller:</p>
  
  <pre><code>&lt;?php
  
  class MyController {
      public function route_method(Request $request) {
          // some code
          $success = $this-&gt;private_method($request-&gt;get('get_variable'));
          // some code
          return \response()-&gt;json(['results' =&gt; $success]);
      }
  
      private function private_method($data) {
          // some code, calling 3rd party service
          return $some_value;
      }
  }
  </code></pre>
  
  <p>And the following corresponding route in Lumen application <code>web.php</code>:</p>
  
  <pre><code>&lt;?php
  
  $app-&gt;get('/endpoint', ['uses' =&gt; 'MyController@route_method']);
  </code></pre>
  
  <p>Now I want to write the unit test that confirms the returned response for call <code>/endpoint</code> returns an expected JSON response that contains the key/value pair of <code>'results': true</code>, but without letting <code>route_method()</code> call <code>private_method()</code> by mocking the latter, because - as in the comment - the <code>private_method()</code> calls a 3rd party service and I want to avoid that, so I think I need something like this:</p>
  
  <pre><code>&lt;?php
  
  class RouteTest extends TestCase {
      public function testRouteReturnsExpectedJsonResponse() {
          // need to mock the private_method here somehow first, then...
          $this-&gt;json('GET', '/endpoint', ['get_variable' =&gt; 'get_value'])-&gt;seeJson(['results' =&gt; true]);
      }
  }
  </code></pre>
  
  <p>But how do I make use of <code>Mockery</code> for this purpose, or is there another way to isolate the 3rd party call?</p>