This pull request implements a new method throws() in the assertion DSL. With it, code along the lines of the following can be rewritten to a more concise form:
Before
use lang\IllegalArgumentException;
class FixtureTest {
#[@test]
public function raises_exception() {
$fixture= ... // Code which could also raise IllegalArgumentExceptions
try {
$fixture->test(null);
$this->fail('No exception raised', null, IllegalArgumentException::class);
} catch (IllegalArgumentException $expected) {
// OK
}
}
}
After
use lang\IllegalArgumentException;
class FixtureTest {
#[@test]
public function raises_exception() {
$fixture= ... // Code which could also raise IllegalArgumentExceptions
Assert::throws(IllegalArgumentException::class, function() use($fixture) {
$fixture->test(null);
});
}
}
This pull request implements a new method
throws()
in the assertion DSL. With it, code along the lines of the following can be rewritten to a more concise form:Before
After