class ExceptionTest extends PHPUnit_framework_TestCase{ public function testException() { $this->expectException(InvalidArgumentException::class); // or for PHPUnit < 5.2 // $this->setExpectedException(InvalidArgumentException::class); //...and then add your test pre that generates the exception exampleMethod($anInvalidArgument); }}


