From db85915c2f04ec68cd8cbb724a7fd340a8a30702 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 23 Oct 2022 22:48:30 +0200 Subject: [PATCH] Migrated BackwardsCompatibleProblemDetailsHandlerTest to use PHPUnit mocks --- .../BackwardsCompatibleProblemDetailsHandlerTest.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/module/Rest/test/Middleware/ErrorHandler/BackwardsCompatibleProblemDetailsHandlerTest.php b/module/Rest/test/Middleware/ErrorHandler/BackwardsCompatibleProblemDetailsHandlerTest.php index 00dddb2f..ab468803 100644 --- a/module/Rest/test/Middleware/ErrorHandler/BackwardsCompatibleProblemDetailsHandlerTest.php +++ b/module/Rest/test/Middleware/ErrorHandler/BackwardsCompatibleProblemDetailsHandlerTest.php @@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Rest\Middleware\ErrorHandler; use Laminas\Diactoros\ServerRequestFactory; use PHPUnit\Framework\TestCase; -use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Core\Exception\ValidationException; @@ -16,8 +15,6 @@ use Throwable; class BackwardsCompatibleProblemDetailsHandlerTest extends TestCase { - use ProphecyTrait; - private BackwardsCompatibleProblemDetailsHandler $handler; protected function setUp(): void @@ -34,13 +31,12 @@ class BackwardsCompatibleProblemDetailsHandlerTest extends TestCase Throwable $thrownException, string $expectedException, ): void { - $handler = $this->prophesize(RequestHandlerInterface::class); - $handle = $handler->handle($request)->willThrow($thrownException); + $handler = $this->createMock(RequestHandlerInterface::class); + $handler->expects($this->once())->method('handle')->with($request)->willThrowException($thrownException); $this->expectException($expectedException); - $handle->shouldBeCalledOnce(); - $this->handler->process($request, $handler->reveal()); + $this->handler->process($request, $handler); } public function provideExceptions(): iterable