title: Mock an Exception in phpUnit
body: <p>The method I am trying to test has a try catch like</p>
  
  <pre><code>try {
      $fooClass-&gt;doStuff(); // Throws \Lib\Custom\Exception
  } 
  catch (\Lib\Custom\Exception $exception) {
      return false;
  }
  </code></pre>
  
  <p>I want to test if the return is false, but the custom exception is not loaded when my tests are executed.</p>
  
  <p>Php unit has the option of mocking classes, but I can't seem to use this for Exceptions.</p>
  
  <pre><code>$exceptionMock= $this-&gt;getMockBuilder(\Lib\Custom\Exception::class)-&gt;getMock();
  
  $fooClassMock = $this-&gt;getMockBuilder(fooClass::class)-&gt;getMock()
       -&gt;method('doStuff')
       -&gt;willThrowException($exceptionMock);
  </code></pre>
  
  <p>Gives me the folowing exception: </p>
  
  <pre><code>Argument 1 passed to 
  PHPUnit_Framework_MockObject_Builder_InvocationMocker::willThrowException() 
  must be an instance of Exception, instance of Mock_Exception_c4dd9394 given
  </code></pre>
  
  <p>How to properly mock this Exception to test the function?</p>