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

如何检查phpUnit 6中的异常和异常消息?,phpunit,Phpunit,在phpunit5中,我们能够设置预期的类名,然后检查它的错误消息 $this->setExpectedException('Cake\Network\Exception\NotFoundException'); $this->assertEquals('Not Found', $this->_exception->getMessage()); 如何在PhpUnit 6中执行相同的操作 $this->expectException(NotFoundExceptio

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

$this->setExpectedException('Cake\Network\Exception\NotFoundException');
$this->assertEquals('Not Found', $this->_exception->getMessage());
如何在PhpUnit 6中执行相同的操作

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