title: Testing exceptions in PHPunit always fails
body: <p>I have few custom exceptions in PHP:</p>
  
  <pre><code>class MainException extends Exception {};
  class ExceptionOne extends MainException {};
  class ExceptionTwo extends MainException {};
  </code></pre>
  
  <p>And I'm using them in my class in two simple methods:</p>
  
  <pre><code>public function firstFunction($param) {
      if ($some_condition) {
          // do whatever
      } else {
          throw new ExceptionOne();
      }
  }
  
  public function secondFunction($param) {
      if ($some_condition) {
          // do whatever
      } else {
          throw new ExceptionTwo();
      }
  }
  </code></pre>
  
  <p>I also have a PHPUnit test for both of exceptions, similar to this:</p>
  
  <pre><code>public function testFirstException() {
      try {
          // anything
      } catch (Exception $e) {
          $this-&gt;assertType('ExceptionOne', $e);
          $this-&gt;assertType('MainException', $e);
      }
  }
  public function testSecondException() {
      try {
          // anything
      } catch (Exception $e) {
          $this-&gt;assertType('ExceptionTwo', $e);
          $this-&gt;assertType('MainException', $e);
      }
  }
  </code></pre>
  
  <p>If I test my class in browser and intentionally make my functions fail (with same stuff as in PHPUnit test) I can see <code>ExceptionOne</code> and <code>ExceptionTwo</code> are raised whenever needed. However, when I test it with PHPUnit I always get a failure:</p>
  
  <pre><code>1) testSecondException(SomeTest)
  Failed asserting that &lt;PHPUnit_Framework_ExpectationFailedException&gt; is an instance of class "ExceptionTwo".
  C:\test.php:67
  </code></pre>
  
  <p>Line 67 is<br>
  <code>$this-&gt;assertType('ExceptionTwo', $e);</code><br>
  and it fails here no matter what I try. I'm pretty sure that my condition in <code>secondFunction</code> works correct. The first test (<code>testFirstException</code>) works perfectly and I never get a failure like in the second one.<br>
  I'd like to add that I shouldn't change PHPUnit test here!</p>
  
  <p>What am I doing wrong here??</p>