diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 912df7a..9652006 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ac29fc6..094679c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout diff --git a/README.md b/README.md index eaeb466..3f36cd4 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ Documentation is available at: https://docs.dotkernel.org/dot-errorhandler/ [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/blob/5.0/LICENSE) -[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml/badge.svg?branch=5.x)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-errorhandler/branch/5.0/graph/badge.svg?token=0KIJARS5RS)](https://codecov.io/gh/dotkernel/dot-errorhandler) -[![PHPStan](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml/badge.svg?branch=5.x)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml) ## Adding the error handler diff --git a/composer.json b/composer.json index 84c5fbf..0b26a0c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ } }, "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "dotkernel/dot-log": "^5.3", "laminas/laminas-diactoros": "^3.8.0", "laminas/laminas-stdlib": "^3.21", @@ -37,7 +37,7 @@ "mikey179/vfsstream": "^1.6.12", "phpstan/phpstan": "^2.2.5", "phpstan/phpstan-phpunit": "^2.0.18", - "phpunit/phpunit": "^10.5.64" + "phpunit/phpunit": "^12.5.22" }, "autoload": { "psr-4": { diff --git a/docs/book/v5/overview.md b/docs/book/v5/overview.md index 3a32091..9435e2f 100644 --- a/docs/book/v5/overview.md +++ b/docs/book/v5/overview.md @@ -22,9 +22,9 @@ [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/blob/5.0/LICENSE) -[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml/badge.svg?branch=5.x)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-errorhandler/branch/5.0/graph/badge.svg?token=0KIJARS5RS)](https://codecov.io/gh/dotkernel/dot-errorhandler) -[![PHPStan](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml/badge.svg?branch=5.x)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml) ## Features diff --git a/phpunit.xml b/phpunit.xml index ef7dc50..00b4aa4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + ./test diff --git a/test/ErrorHandlerFactoryTest.php b/test/ErrorHandlerFactoryTest.php index a30aab8..d457690 100644 --- a/test/ErrorHandlerFactoryTest.php +++ b/test/ErrorHandlerFactoryTest.php @@ -27,7 +27,7 @@ class ErrorHandlerFactoryTest extends TestCase public function setUp(): void { $this->container = $this->createMock(ContainerInterface::class); - $this->responseFactory = fn(): ResponseInterface => $this->createMock(ResponseInterface::class); + $this->responseFactory = fn(): ResponseInterface => $this->createStub(ResponseInterface::class); } /** @@ -61,7 +61,7 @@ public function testWillCreateWithErrorResponseGenerator(): void $this->container->method('get') ->willReturnMap([ - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); diff --git a/test/ErrorHandlerTest.php b/test/ErrorHandlerTest.php index 0f2b2a5..f601b23 100644 --- a/test/ErrorHandlerTest.php +++ b/test/ErrorHandlerTest.php @@ -8,8 +8,10 @@ use Dot\ErrorHandler\ErrorHandler as Subject; use ErrorException; use Laminas\Stratigility\Middleware\ErrorResponseGenerator; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -21,10 +23,11 @@ use function error_reporting; +#[AllowMockObjectsWithoutExpectations] class ErrorHandlerTest extends TestCase { private Subject $subject; - private MockObject&ServerRequestInterface $serverRequest; + private Stub&ServerRequestInterface $serverRequest; private MockObject&ResponseInterface $response; private ErrorResponseGenerator $errorResponseGenerator; /** @var callable():ResponseInterface $responseFactory */ @@ -39,7 +42,7 @@ class ErrorHandlerTest extends TestCase public function setUp(): void { $this->response = $this->createMock(ResponseInterface::class); - $this->serverRequest = $this->createMock(ServerRequestInterface::class); + $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); $this->handler = $this->createMock(RequestHandlerInterface::class); diff --git a/test/LogErrorHandlerFactoryTest.php b/test/LogErrorHandlerFactoryTest.php index d64583b..6803216 100644 --- a/test/LogErrorHandlerFactoryTest.php +++ b/test/LogErrorHandlerFactoryTest.php @@ -9,6 +9,7 @@ use Dot\ErrorHandler\LogErrorHandlerFactory; use InvalidArgumentException; use Mezzio\Middleware\ErrorResponseGenerator; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -32,7 +33,7 @@ class LogErrorHandlerFactoryTest extends TestCase public function setUp(): void { $this->container = $this->createMock(ContainerInterface::class); - $this->responseFactory = fn(): ResponseInterface => $this->createMock(ResponseInterface::class); + $this->responseFactory = fn(): ResponseInterface => $this->createStub(ResponseInterface::class); } /** @@ -84,6 +85,7 @@ public function testWillNotCreateWithMissingLoggerKey(): void * @throws NotFoundExceptionInterface * @throws Exception */ + #[AllowMockObjectsWithoutExpectations] public function testWillCreateWithValidConfigAndMissingLogger(): void { $this->container->method('get') @@ -102,7 +104,7 @@ public function testWillCreateWithValidConfigAndMissingLogger(): void . '][' . LogErrorHandlerFactory::ERROR_HANDLER_LOGGER_KEY . ']', null, ], - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); @@ -117,7 +119,7 @@ public function testWillCreateWithValidConfigAndMissingLogger(): void */ public function testWillCreateWithoutExtraProviderConfig(): void { - $logger = $this->createMock(LoggerInterface::class); + $logger = $this->createStub(LoggerInterface::class); $this->container->method('has') ->with(ErrorResponseGenerator::class) @@ -139,7 +141,7 @@ public function testWillCreateWithoutExtraProviderConfig(): void . LogErrorHandlerFactory::ERROR_HANDLER_LOGGER_KEY . ']', $logger, ], - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); @@ -154,7 +156,7 @@ public function testWillCreateWithoutExtraProviderConfig(): void */ public function testWillCreateWithEmptyExtraProviderConfig(): void { - $logger = $this->createMock(LoggerInterface::class); + $logger = $this->createStub(LoggerInterface::class); $this->container->method('has') ->with(ErrorResponseGenerator::class) @@ -177,7 +179,7 @@ public function testWillCreateWithEmptyExtraProviderConfig(): void . LogErrorHandlerFactory::ERROR_HANDLER_LOGGER_KEY . ']', $logger, ], - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); @@ -192,7 +194,7 @@ public function testWillCreateWithEmptyExtraProviderConfig(): void */ public function testWillCreateWithInvalidExtraProviderConfig(): void { - $logger = $this->createMock(LoggerInterface::class); + $logger = $this->createStub(LoggerInterface::class); $this->container->method('has') ->with(ErrorResponseGenerator::class) @@ -217,7 +219,7 @@ public function testWillCreateWithInvalidExtraProviderConfig(): void . LogErrorHandlerFactory::ERROR_HANDLER_LOGGER_KEY . ']', $logger, ], - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); @@ -232,7 +234,7 @@ public function testWillCreateWithInvalidExtraProviderConfig(): void */ public function testWillCreateWithValidConfig(): void { - $logger = $this->createMock(LoggerInterface::class); + $logger = $this->createStub(LoggerInterface::class); $this->container->method('has') ->with(ErrorResponseGenerator::class) @@ -254,7 +256,7 @@ public function testWillCreateWithValidConfig(): void . LogErrorHandlerFactory::ERROR_HANDLER_LOGGER_KEY . ']', $logger, ], - [ErrorResponseGenerator::class, $this->createMock(ErrorResponseGenerator::class)], + [ErrorResponseGenerator::class, $this->createStub(ErrorResponseGenerator::class)], [ResponseInterface::class, $this->responseFactory], ]); diff --git a/test/LogErrorHandlerTest.php b/test/LogErrorHandlerTest.php index 4281094..8fdc922 100644 --- a/test/LogErrorHandlerTest.php +++ b/test/LogErrorHandlerTest.php @@ -19,8 +19,10 @@ use Laminas\Stratigility\Middleware\ErrorResponseGenerator; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Http\Message\ResponseInterface; @@ -35,10 +37,11 @@ use function error_reporting; use function file_get_contents; +#[AllowMockObjectsWithoutExpectations] class LogErrorHandlerTest extends TestCase { private Subject $subject; - private MockObject&ServerRequestInterface $serverRequest; + private Stub&ServerRequestInterface $serverRequest; private MockObject&ResponseInterface $response; /** @var callable():ResponseInterface $responseFactory */ private $responseFactory; @@ -54,7 +57,7 @@ class LogErrorHandlerTest extends TestCase public function setUp(): void { $this->response = $this->createMock(ResponseInterface::class); - $this->serverRequest = $this->createMock(ServerRequestInterface::class); + $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); $this->handler = $this->createMock(RequestHandlerInterface::class); @@ -63,7 +66,7 @@ public function setUp(): void $this->subject = new LogErrorHandler( $this->responseFactory, $this->errorResponseGenerator, - $this->createMock(LoggerInterface::class) + $this->createStub(LoggerInterface::class) ); $this->exception = new RuntimeException('Not Implemented', 501); $this->fileSystem = vfsStream::setup('root', 0644, ['log']);