PHP code example of digitickets / phpunit-errorhandler

1. Go to this page and download the library: Download digitickets/phpunit-errorhandler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitickets / phpunit-errorhandler example snippets



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