如何在 phpUnit 6 中检查异常和异常消息?

Eug*_*rov 2 phpunit

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

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

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

Eug*_*rov 5

$this->expectException(NotFoundException::class);
$this->expectExceptionMessage('Not Found');
Run Code Online (Sandbox Code Playgroud)