PHP code example of devlop / phpunit-exception-assertions
1. Go to this page and download the library: Download devlop/phpunit-exception-assertions 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/ */
devlop / phpunit-exception-assertions example snippets
use Devlop\PHPUnit\ExceptionAssertions;
class YourTest extends TestCase
{
use ExceptionAssertions;
}
$this->assertExceptionThrown(\InvalidArgumentException::class, function () : void {
// code that should throw the expected exception
});
$this->assertExceptionNotThrown(\InvalidArgumentException::class, function () : void {
// code that should not throw the exception
});
$this->assertNoExceptionsThrown(function () : void {
// code that should not throw any exceptions
});