From 768cbd72c069eac32d72c1b3134cd8da27539521 Mon Sep 17 00:00:00 2001 From: OStefan2001 Date: Thu, 26 Nov 2026 14:13:25 +0200 Subject: [PATCH 1/3] updated codebase, composer, workflow and tests --- .github/workflows/codecov.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- composer.json | 4 ++-- phpunit.xml | 2 +- test/ErrorHandlerFactoryTest.php | 10 +++++----- test/ErrorHandlerTest.php | 13 +++++++------ test/LogErrorHandlerFactoryTest.php | 26 +++++++++++++------------- test/LogErrorHandlerTest.php | 15 ++++++++------- 8 files changed, 38 insertions(+), 36 deletions(-) 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/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/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..8555abf 100644 --- a/test/ErrorHandlerFactoryTest.php +++ b/test/ErrorHandlerFactoryTest.php @@ -8,7 +8,7 @@ use Dot\ErrorHandler\ErrorHandlerFactory; use Mezzio\Middleware\ErrorResponseGenerator; 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\Container\ContainerInterface; @@ -17,7 +17,7 @@ class ErrorHandlerFactoryTest extends TestCase { - private MockObject|ContainerInterface $container; + private Stub|ContainerInterface $container; /** @var callable $responseFactory */ private $responseFactory; @@ -26,8 +26,8 @@ class ErrorHandlerFactoryTest extends TestCase */ public function setUp(): void { - $this->container = $this->createMock(ContainerInterface::class); - $this->responseFactory = fn(): ResponseInterface => $this->createMock(ResponseInterface::class); + $this->container = $this->createStub(ContainerInterface::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..759b9d0 100644 --- a/test/ErrorHandlerTest.php +++ b/test/ErrorHandlerTest.php @@ -10,6 +10,7 @@ use Laminas\Stratigility\Middleware\ErrorResponseGenerator; 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; @@ -24,13 +25,13 @@ class ErrorHandlerTest extends TestCase { private Subject $subject; - private MockObject&ServerRequestInterface $serverRequest; - private MockObject&ResponseInterface $response; + private Stub&ServerRequestInterface $serverRequest; + private Stub&ResponseInterface $response; private ErrorResponseGenerator $errorResponseGenerator; /** @var callable():ResponseInterface $responseFactory */ private $responseFactory; private MockObject&StreamInterface $body; - private MockObject&RequestHandlerInterface $handler; + private Stub&RequestHandlerInterface $handler; private Throwable $exception; /** @@ -38,10 +39,10 @@ class ErrorHandlerTest extends TestCase */ public function setUp(): void { - $this->response = $this->createMock(ResponseInterface::class); - $this->serverRequest = $this->createMock(ServerRequestInterface::class); + $this->response = $this->createStub(ResponseInterface::class); + $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); - $this->handler = $this->createMock(RequestHandlerInterface::class); + $this->handler = $this->createStub(RequestHandlerInterface::class); $this->responseFactory = fn(): ResponseInterface => $this->response; $this->errorResponseGenerator = new ErrorResponseGenerator(); diff --git a/test/LogErrorHandlerFactoryTest.php b/test/LogErrorHandlerFactoryTest.php index d64583b..3919244 100644 --- a/test/LogErrorHandlerFactoryTest.php +++ b/test/LogErrorHandlerFactoryTest.php @@ -10,7 +10,7 @@ use InvalidArgumentException; use Mezzio\Middleware\ErrorResponseGenerator; 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\Container\ContainerInterface; @@ -22,7 +22,7 @@ class LogErrorHandlerFactoryTest extends TestCase { - private ContainerInterface&MockObject $container; + private ContainerInterface&Stub $container; /** @var callable $responseFactory */ private $responseFactory; @@ -31,8 +31,8 @@ class LogErrorHandlerFactoryTest extends TestCase */ public function setUp(): void { - $this->container = $this->createMock(ContainerInterface::class); - $this->responseFactory = fn(): ResponseInterface => $this->createMock(ResponseInterface::class); + $this->container = $this->createStub(ContainerInterface::class); + $this->responseFactory = fn(): ResponseInterface => $this->createStub(ResponseInterface::class); } /** @@ -102,7 +102,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 +117,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 +139,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 +154,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 +177,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 +192,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 +217,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 +232,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 +254,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..231b86c 100644 --- a/test/LogErrorHandlerTest.php +++ b/test/LogErrorHandlerTest.php @@ -21,6 +21,7 @@ use org\bovigo\vfs\vfsStreamDirectory; 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; @@ -38,12 +39,12 @@ class LogErrorHandlerTest extends TestCase { private Subject $subject; - private MockObject&ServerRequestInterface $serverRequest; - private MockObject&ResponseInterface $response; + private Stub&ServerRequestInterface $serverRequest; + private Stub&ResponseInterface $response; /** @var callable():ResponseInterface $responseFactory */ private $responseFactory; private MockObject&StreamInterface $body; - private MockObject&RequestHandlerInterface $handler; + private Stub&RequestHandlerInterface $handler; private Throwable $exception; private ErrorResponseGenerator $errorResponseGenerator; private vfsStreamDirectory $fileSystem; @@ -53,17 +54,17 @@ class LogErrorHandlerTest extends TestCase */ public function setUp(): void { - $this->response = $this->createMock(ResponseInterface::class); - $this->serverRequest = $this->createMock(ServerRequestInterface::class); + $this->response = $this->createStub(ResponseInterface::class); + $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); - $this->handler = $this->createMock(RequestHandlerInterface::class); + $this->handler = $this->createStub(RequestHandlerInterface::class); $this->responseFactory = fn(): ResponseInterface => $this->response; $this->errorResponseGenerator = new ErrorResponseGenerator(); $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']); From 08e9f1a443333b17e835301400cf376ba87ffd10 Mon Sep 17 00:00:00 2001 From: OStefan2001 Date: Thu, 26 Nov 2026 14:34:57 +0200 Subject: [PATCH 2/3] updated tests --- test/ErrorHandlerFactoryTest.php | 6 +++--- test/ErrorHandlerTest.php | 10 ++++++---- test/LogErrorHandlerFactoryTest.php | 8 +++++--- test/LogErrorHandlerTest.php | 10 ++++++---- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/test/ErrorHandlerFactoryTest.php b/test/ErrorHandlerFactoryTest.php index 8555abf..d457690 100644 --- a/test/ErrorHandlerFactoryTest.php +++ b/test/ErrorHandlerFactoryTest.php @@ -8,7 +8,7 @@ use Dot\ErrorHandler\ErrorHandlerFactory; use Mezzio\Middleware\ErrorResponseGenerator; use PHPUnit\Framework\MockObject\Exception; -use PHPUnit\Framework\MockObject\Stub; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -17,7 +17,7 @@ class ErrorHandlerFactoryTest extends TestCase { - private Stub|ContainerInterface $container; + private MockObject|ContainerInterface $container; /** @var callable $responseFactory */ private $responseFactory; @@ -26,7 +26,7 @@ class ErrorHandlerFactoryTest extends TestCase */ public function setUp(): void { - $this->container = $this->createStub(ContainerInterface::class); + $this->container = $this->createMock(ContainerInterface::class); $this->responseFactory = fn(): ResponseInterface => $this->createStub(ResponseInterface::class); } diff --git a/test/ErrorHandlerTest.php b/test/ErrorHandlerTest.php index 759b9d0..f601b23 100644 --- a/test/ErrorHandlerTest.php +++ b/test/ErrorHandlerTest.php @@ -8,6 +8,7 @@ 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; @@ -22,16 +23,17 @@ use function error_reporting; +#[AllowMockObjectsWithoutExpectations] class ErrorHandlerTest extends TestCase { private Subject $subject; private Stub&ServerRequestInterface $serverRequest; - private Stub&ResponseInterface $response; + private MockObject&ResponseInterface $response; private ErrorResponseGenerator $errorResponseGenerator; /** @var callable():ResponseInterface $responseFactory */ private $responseFactory; private MockObject&StreamInterface $body; - private Stub&RequestHandlerInterface $handler; + private MockObject&RequestHandlerInterface $handler; private Throwable $exception; /** @@ -39,10 +41,10 @@ class ErrorHandlerTest extends TestCase */ public function setUp(): void { - $this->response = $this->createStub(ResponseInterface::class); + $this->response = $this->createMock(ResponseInterface::class); $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); - $this->handler = $this->createStub(RequestHandlerInterface::class); + $this->handler = $this->createMock(RequestHandlerInterface::class); $this->responseFactory = fn(): ResponseInterface => $this->response; $this->errorResponseGenerator = new ErrorResponseGenerator(); diff --git a/test/LogErrorHandlerFactoryTest.php b/test/LogErrorHandlerFactoryTest.php index 3919244..6803216 100644 --- a/test/LogErrorHandlerFactoryTest.php +++ b/test/LogErrorHandlerFactoryTest.php @@ -9,8 +9,9 @@ use Dot\ErrorHandler\LogErrorHandlerFactory; use InvalidArgumentException; use Mezzio\Middleware\ErrorResponseGenerator; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; -use PHPUnit\Framework\MockObject\Stub; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -22,7 +23,7 @@ class LogErrorHandlerFactoryTest extends TestCase { - private ContainerInterface&Stub $container; + private ContainerInterface&MockObject $container; /** @var callable $responseFactory */ private $responseFactory; @@ -31,7 +32,7 @@ class LogErrorHandlerFactoryTest extends TestCase */ public function setUp(): void { - $this->container = $this->createStub(ContainerInterface::class); + $this->container = $this->createMock(ContainerInterface::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') diff --git a/test/LogErrorHandlerTest.php b/test/LogErrorHandlerTest.php index 231b86c..8fdc922 100644 --- a/test/LogErrorHandlerTest.php +++ b/test/LogErrorHandlerTest.php @@ -19,6 +19,7 @@ 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; @@ -36,15 +37,16 @@ use function error_reporting; use function file_get_contents; +#[AllowMockObjectsWithoutExpectations] class LogErrorHandlerTest extends TestCase { private Subject $subject; private Stub&ServerRequestInterface $serverRequest; - private Stub&ResponseInterface $response; + private MockObject&ResponseInterface $response; /** @var callable():ResponseInterface $responseFactory */ private $responseFactory; private MockObject&StreamInterface $body; - private Stub&RequestHandlerInterface $handler; + private MockObject&RequestHandlerInterface $handler; private Throwable $exception; private ErrorResponseGenerator $errorResponseGenerator; private vfsStreamDirectory $fileSystem; @@ -54,10 +56,10 @@ class LogErrorHandlerTest extends TestCase */ public function setUp(): void { - $this->response = $this->createStub(ResponseInterface::class); + $this->response = $this->createMock(ResponseInterface::class); $this->serverRequest = $this->createStub(ServerRequestInterface::class); $this->body = $this->createMock(StreamInterface::class); - $this->handler = $this->createStub(RequestHandlerInterface::class); + $this->handler = $this->createMock(RequestHandlerInterface::class); $this->responseFactory = fn(): ResponseInterface => $this->response; $this->errorResponseGenerator = new ErrorResponseGenerator(); From c2139e9a8bb2f9a24cc826d9b2d4db9ec3c49a12 Mon Sep 17 00:00:00 2001 From: OStefan2001 Date: Fri, 27 Nov 2026 17:31:34 +0200 Subject: [PATCH 3/3] updated overview and readme --- README.md | 4 ++-- docs/book/v5/overview.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/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