FactoryGirl\Tests\Provider\Doctrine\Fixtures\TestCase::assertThrows PHP Method

assertThrows() protected method

protected assertThrows ( $func, $exceptionType = '\Exception' ) : Exception
return Exception
    protected function assertThrows($func, $exceptionType = '\\Exception')
    {
        try {
            $func();
        } catch (Exception $e) {
        }
        if (!isset($e)) {
            $this->fail("Expected {$exceptionType} but nothing was thrown");
        }
        if ($e instanceof PHPUnit_Framework_Error) {
            $this->fail('Expected exception but got a PHP error: ' . $e->getMessage());
        }
        if (!$e instanceof $exceptionType) {
            $this->fail("Excpected {$exceptionType} but " . get_class($e) . " was thrown");
        }
        return $e;
    }