如何检查phpUnit 6中的异常和EXCEPTION MESSAGE?

时间:2017-12-11 18:46:33

标签: phpunit

在PhpUnit 5中,我们能够设置预期的类名,然后检查它的错误信息

$this->setExpectedException('Cake\Network\Exception\NotFoundException');
$this->assertEquals('Not Found', $this->_exception->getMessage());

如何在PhpUnit 6中做同样的事情?

1 个答案:

答案 0 :(得分:2)

$this->expectException(NotFoundException::class);
$this->expectExceptionMessage('Not Found');