vgirol/phpunit-exception

Add some utilities to test exceptions when using PHPUnit


Keywords
vgirol, Phpunit-Exception
License
MIT

Documentation

Phpunit-Exception

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Infection MSI Total Downloads

Technologies

  • PHP 7.3+
  • PHPUnit 9+

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require-dev": {
        "vgirol/phpunit-exception": "dev-master"
    }
}

And then run composer install from the terminal.

Quick Installation

Above installation can also be simplified by using the following command:

$ composer require vgirol/phpunit-exception

Usage

use PHPUnit\Framework\TestCase as BaseTestCase;
use VGirol\PhpunitException\SetExceptionsTrait;

class TestCase extends BaseTestCase
{
    use SetExceptionsTrait;

    public function test()
    {
        $className = \Exception::class;
        $message = 'Error';
        $code = 666;

        $this->setFailure($className, $message, $code);

        throw new \Exception($message, $code);
    }
}

Documentation

The API documentation is available in XHTML format at the url http://Phpunit-Exception.girol.fr/docs/ref/index.html.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email vincent@girol.fr instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.