rquadling / phpunit-errorhandler
此包已被废弃且不再维护。作者建议使用digitickets/phpunit-errorhandler包代替。
一个简单的特质,可以添加到您的PHPUnit测试中,允许您跟踪和测试PHP错误、警告和通知
4.1.1
2018-09-06 11:35 UTC
Requires
- php: >=7
Requires (Dev)
- phpunit/phpunit: ^6
README
PHPUnit ErrorHandler
一种替代的单元测试PHP错误的方法。
虽然您可以使用PHPUnit内置的行为将所有错误、警告和通知转换为异常,但此包允许您分别跟踪所有PHP错误,包括用户生成的错误。
代码以特质的形式提供,并基于使用PHPUnit测试错误条件
以下是一个使用示例
<?php use DigiTickets\PHPUnit\ErrorHandler; class TestErrorHandling extends \PHPUnit\Framework\TestCase { use ErrorHandler; public function testSomethingGeneratedAnError() { // Run something that will produce an error, warning or notice. // For example, a E_USER_NOTICE of 'Incompatible type ignored' can be tested as follows: $this->assertError('Incompatible type ignored', E_USER_NOTICE); } public function testSomethingDidNotGenerateAnError() { // Run something that should not produce an error, warning or notice. $this->assertNoErrors(); } }
从V3.0.0升级到V4.0.0
感谢imbrish,升级非常简单。
在之前的版本中,您需要以下设置逻辑。
protected function setUp()
{
// Set the error handler.
$this->setUpErrorHandler();
}
现在您不需要了。您可以移除$this->setUpErrorHandler();
调用。如果您现在有一个空的setup()
函数,也可以将其删除!