定制 digitickets/phpunit-errorhandler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitickets/phpunit-errorhandler

最新稳定版本:4.1.1

Composer 安装命令:

composer require digitickets/phpunit-errorhandler

包简介

A simple trait to add to your PHPUnit test allowing you to track and test PHP errors, warnings and notices

README 文档

README

Travis Build Status Scrutinizer Build Status Scrutinizer Code Coverage GitHub issues

PHP Version Stable Version

Total Packagist Downloads Monthly Packagist Downloads Daily Packagist Downloads

PHPUnit ErrorHandler

An alternative approach to unit testing PHP errors.

Whilst you can use PHPUnit's built-in behaviour of converting all errors, warnings and notices to exceptions, this package allows you to track all PHP errors, including user generated errors, separately.

The code is supplied as a trait and is based upon Error Condition Testing with PHPUnit

Here is an example use case:

<?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();
    }
}

Upgrading from V3.0.0 to V4.0.0

Thanks to imbrish, the upgrade is extremely simple.

In previous versions, you were required to have the following setup logic.

protected function setUp()
{
    // Set the error handler.
    $this->setUpErrorHandler();
}

Now you don't. You can remove the $this->setUpErrorHandler(); call. If you now have an empty setup() function, you can remove that also!

统计信息

  • 总下载量: 64.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CPL-1.0
  • 更新时间: 2016-11-17