Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
- "8.6"

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
- "8.6"

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v5/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="dot-errorhandler Test Suite">
<directory>./test</directory>
Expand Down
4 changes: 2 additions & 2 deletions test/ErrorHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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],
]);

Expand Down
7 changes: 5 additions & 2 deletions test/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -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);

Expand Down
22 changes: 12 additions & 10 deletions test/LogErrorHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -84,6 +85,7 @@ public function testWillNotCreateWithMissingLoggerKey(): void
* @throws NotFoundExceptionInterface
* @throws Exception
*/
#[AllowMockObjectsWithoutExpectations]
public function testWillCreateWithValidConfigAndMissingLogger(): void
{
$this->container->method('get')
Expand All @@ -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],
]);

Expand All @@ -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)
Expand All @@ -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],
]);

Expand All @@ -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)
Expand All @@ -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],
]);

Expand All @@ -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)
Expand All @@ -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],
]);

Expand All @@ -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)
Expand All @@ -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],
]);

Expand Down
9 changes: 6 additions & 3 deletions test/LogErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);

Expand All @@ -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']);
Expand Down