title: Controller unit test in slim3
body: <p>At the outset, I would like to say - I'm new in unit testing in PHP (phpunit).
  In my new project (slim3 framework) I would like to test my controllers for example LoginController. </p>
  
  <p>My idea is (in unit test method)</p>
  
  <ul>
  <li>Create instance of <code>LoginController</code></li>
  <li>Mock some services in controller (DI)</li>
  <li>Execute method which is response for request (in my controllers method <code>__invoke</code>)</li>
  </ul>
  
  <p>My problem is about parameters for <code>__invoke</code> method. 
  In Slim3 callable method for request has two first params:</p>
  
  <p><code>RequestInterface $request</code> and <code>ResponseInterface $response</code></p>
  
  <p>How can I create this parameters in my unit test class? I was searching for some examples for this issue but without success. </p>
  
  <p>Any suggestions?</p>
  
  <p>I've found some code in Slim3 tests to mock request:</p>
  
  <pre><code>protected function requestFactory()
  {
      $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
      $headers = new Headers();
      $cookies = array(
          'user' =&gt; 'john',
          'id' =&gt; '123',
      );
      $env = Slim\Http\Environment::mock();
      $serverParams = $env-&gt;all();
      $body = new Body(fopen('php://temp', 'r+'));
      $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
  
      return $request;
  }
  </code></pre>
  
  <p>But I'm not sure that is good way. </p>
  
  <p>Thanks for any help</p>