3 ms·
PHPUnit has this in the comment annotations /** * Tests that thisShouldThrowFooBarException throws FooBarException * * @expectedException F
by jaredmcateer 13y ago
PHPUnit has this in the comment annotations
/**
* Tests that thisShouldThrowFooBarException throws FooBarException
*
* @expectedException FooBarException
*/
public function testFooBarException() {
thisShouldThrowFooBarException();
}
but I much prefer
/**
* Tests that thisShouldThrowFooBarException throws FooBarException
*/
public function testFooBarException() {
$this->setExpectedException('FooBarException');
thisShouldThrowFooBarException();
}
Much more explicit and you're less likely to miss it when trying to grok someone else's unittest.