2017 © Pedro Peláez
 

library phpunit-errorhandler

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

image

digitickets/phpunit-errorhandler

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

  • Wednesday, January 3, 2018
  • by Digitickets
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12,708 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 11 % Grown

The README.md

Travis Build Status Scrutinizer Build Status Scrutinizer Code Coverage GitHub issues, (*1)

PHP Version Stable Version, (*2)

Total Packagist Downloads Monthly Packagist Downloads Daily Packagist Downloads, (*3)

PHPUnit ErrorHandler

An alternative approach to unit testing PHP errors., (*4)

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., (*5)

The code is supplied as a trait and is based upon Error Condition Testing with PHPUnit, (*6)

Here is an example use case:, (*7)

<?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., (*8)

In previous versions, you were required to have the following setup logic., (*9)

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!, (*10)

The Versions

03/01 2018

dev-master

9999999-dev

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

  Sources   Download

CPL-1.0

The Requires

  • php >=7

 

The Development Requires

by Richard Quadling

10/11 2017

4.0.0

4.0.0.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=7

 

The Development Requires

by Richard Quadling

08/02 2017

3.0.0

3.0.0.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=7

 

The Development Requires

by Richard Quadling

17/11 2016

2.0.0

2.0.0.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=5.4

 

The Development Requires

by Richard Quadling

05/10 2016

1.0.3

1.0.3.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=5.4

 

The Development Requires

by Richard Quadling

05/10 2016

1.0.2

1.0.2.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=5.4

 

The Development Requires

by Richard Quadling

29/01 2016

1.0.1

1.0.1.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=5.4

 

The Development Requires

by Richard Quadling

20/01 2016

1.0.0

1.0.0.0

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

  Sources   Download

CPL-1.0

The Requires

  • php >=5.4

 

The Development Requires

by Richard Quadling