neclimdul / phpunit_exceptions
Provides additional methods for consistently testing methods in PHPUnit 9 and 10.
1.0.1
2024-05-03 16:58 UTC
Requires
- php: >=8.1
- phpunit/phpunit: ^9 | ^10 | ^11
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^1.10
- squizlabs/php_codesniffer: ^3.8
- vimeo/psalm: ^5.18
This package is auto-updated.
Last update: 2024-10-20 20:31:45 UTC
README
This projects aims to provide some simple tools to make testing exceptions easier in the PHPUnit testing framework.
It was inspired by similar functionality in Laravel.
Installation
composer require neclimdul/phpunit_exceptions
Usage
<?php
use NecLimDul\PhpUnitExceptions\ExceptionAssertionTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request
use Symfony\Component\HttpKernel\Exception\HttpException;
class MyTest extends TestCase {
use ExceptionAssertionTrait;
public function testBadRequest() {
$request = new Request();
$this->assertThrows(function () use ($request) {
(new MyMiddleware())->handle($request, function ($request) {});
}, HttpException::class);
}
}