From 0b959df84504b7d68c60808fc09e14f3628b11f8 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:37:06 +0100 Subject: [PATCH 1/2] chore: remove phpspec/prophecy --- composer.json | 1 - .../DocumentationNormalizerTest.php | 51 +++-- tests/Controller/GetTokenTest.php | 23 +-- tests/Controller/ResetPasswordTest.php | 15 +- tests/Controller/UpdatePasswordTest.php | 17 +- .../ExceptionEventListenerTest.php | 72 ++++--- .../RequestEventListenerTest.php | 180 +++++++++--------- tests/Manager/Bridge/DoctrineManagerTest.php | 37 ++-- tests/Manager/ForgotPasswordManagerTest.php | 162 ++++++++-------- tests/Manager/PasswordTokenManagerTest.php | 52 +++-- tests/Normalizer/JMSNormalizerTest.php | 15 +- tests/Normalizer/SymfonyNormalizerTest.php | 15 +- tests/ProphecyTrait.php | 123 ------------ 13 files changed, 295 insertions(+), 468 deletions(-) delete mode 100644 tests/ProphecyTrait.php diff --git a/composer.json b/composer.json index a5d18cc..c7de9ad 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ "jms/serializer-bundle": "^1.4 || ^2.3 || ^3.0 || ^4.0", "laminas/laminas-code": "^3.4 || ^4.0", "ocramius/proxy-manager": "^2.0.4", - "phpspec/prophecy": "^1.10", "sebastian/comparator": "^3.0", "symfony/asset": "^5.1 || ^6.0", "symfony/browser-kit": "^5.1 || ^6.0", diff --git a/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php b/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php index c6fc995..246b435 100755 --- a/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php +++ b/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php @@ -16,7 +16,6 @@ use CoopTilleuls\ForgotPasswordBundle\Bridge\ApiPlatform\Serializer\DocumentationNormalizer; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderChainInterface; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\Routing\Route; @@ -29,9 +28,7 @@ */ final class DocumentationNormalizerTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var NormalizerInterface|ObjectProphecy */ private $normalizerMock; @@ -68,41 +65,41 @@ final class DocumentationNormalizerTest extends TestCase protected function setUp(): void { - $this->normalizerMock = $this->prophesize(NormalizerInterface::class); - $this->routerMock = $this->prophesize(RouterInterface::class); - $this->routeCollectionMock = $this->prophesize(RouteCollection::class); - $this->routeMock = $this->prophesize(Route::class); - $this->providerChainMock = $this->prophesize(ProviderChainInterface::class); - $this->providerMock = $this->prophesize(ProviderInterface::class); + $this->normalizerMock = $this->createMock(NormalizerInterface::class); + $this->routerMock = $this->createMock(RouterInterface::class); + $this->routeCollectionMock = $this->createMock(RouteCollection::class); + $this->routeMock = $this->createMock(Route::class); + $this->providerChainMock = $this->createMock(ProviderChainInterface::class); + $this->providerMock = $this->createMock(ProviderInterface::class); $this->normalizer = new DocumentationNormalizer( - $this->normalizerMock->reveal(), - $this->routerMock->reveal(), - $this->providerChainMock->reveal() + $this->normalizerMock, + $this->routerMock, + $this->providerChainMock ); } public function testItSupportsDecoratedSupport(): void { - $this->normalizerMock->supportsNormalization('foo', 'bar')->willReturn(true)->shouldBeCalledOnce(); + $this->normalizerMock->expects($this->once())->method('supportsNormalization')->with('foo', 'bar')->willReturn(true); $this->assertTrue($this->normalizer->supportsNormalization('foo', 'bar')); } public function testItDecoratesNormalizedData(): void { - $this->routerMock->getRouteCollection()->willReturn($this->routeCollectionMock)->shouldBeCalledOnce(); - $this->routeCollectionMock->get('coop_tilleuls_forgot_password.reset')->willReturn($this->routeMock)->shouldBeCalledOnce(); - $this->routeCollectionMock->get('coop_tilleuls_forgot_password.get_token')->willReturn($this->routeMock)->shouldBeCalledOnce(); - $this->routeCollectionMock->get('coop_tilleuls_forgot_password.update')->willReturn($this->routeMock)->shouldBeCalledOnce(); - $this->routeMock->getPath()->willReturn('/api/forgot-password/', '/api/forgot-password/{tokenValue}', '/api/forgot-password/{tokenValue}')->shouldBeCalledTimes(3); + $this->routerMock->expects($this->once())->method('getRouteCollection')->willReturn($this->routeCollectionMock); + $this->routeCollectionMock->expects($this->exactly(3))->method('get') + ->withConsecutive(['coop_tilleuls_forgot_password.reset'], ['coop_tilleuls_forgot_password.get_token'], ['coop_tilleuls_forgot_password.update']) + ->willReturn($this->routeMock); + $this->routeMock->expects($this->exactly(3))->method('getPath')->willReturnOnConsecutiveCalls('/api/forgot-password/', '/api/forgot-password/{tokenValue}', '/api/forgot-password/{tokenValue}'); - $this->providerChainMock->all()->willReturn([ - 'user' => $this->providerMock->reveal(), - 'admin' => $this->providerMock->reveal(), - ])->shouldBeCalledOnce(); - $this->providerMock->getUserPasswordField()->willReturn('password', 'password')->shouldBeCalledTimes(2); - $this->providerMock->getUserAuthorizedFields()->willReturn(['email'], ['username', 'email'])->shouldBeCalledTimes(2); + $this->providerChainMock->expects($this->once())->method('all')->willReturn([ + 'user' => $this->providerMock, + 'admin' => $this->providerMock, + ]); + $this->providerMock->expects($this->exactly(2))->method('getUserPasswordField')->willReturn('password'); + $this->providerMock->expects($this->exactly(2))->method('getUserAuthorizedFields')->willReturnOnConsecutiveCalls(['email'], ['username', 'email']); - $this->normalizerMock->normalize(new \stdClass(), 'bar', [])->willReturn([ + $this->normalizerMock->expects($this->once())->method('normalize')->with(new \stdClass(), 'bar', [])->willReturn([ 'tags' => [['name' => 'Login']], 'paths' => [ '/login' => [ @@ -148,7 +145,7 @@ public function testItDecoratesNormalizedData(): void ], ], ], - ])->shouldBeCalledOnce(); + ]); $this->assertEquals([ 'tags' => [['name' => 'Login'], ['name' => 'Forgot password']], 'paths' => [ diff --git a/tests/Controller/GetTokenTest.php b/tests/Controller/GetTokenTest.php index 96682a1..68f26c6 100755 --- a/tests/Controller/GetTokenTest.php +++ b/tests/Controller/GetTokenTest.php @@ -17,7 +17,6 @@ use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken; use CoopTilleuls\ForgotPasswordBundle\Normalizer\NormalizerInterface; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\HttpFoundation\JsonResponse; @@ -27,9 +26,7 @@ */ final class GetTokenTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; @@ -46,21 +43,17 @@ final class GetTokenTest extends TestCase protected function setUp(): void { - $this->providerMock = $this->prophesize(ProviderInterface::class); - $this->normalizerMock = $this->prophesize(NormalizerInterface::class); - $this->tokenMock = $this->prophesize(AbstractPasswordToken::class); + $this->providerMock = $this->createMock(ProviderInterface::class); + $this->normalizerMock = $this->createMock(NormalizerInterface::class); + $this->tokenMock = $this->createMock(AbstractPasswordToken::class); } public function testGetTokenAction(): void { - $this->providerMock->getPasswordTokenSerializationGroups() - ->willReturn(['foo']) - ->shouldBeCalledOnce(); - $this->normalizerMock->normalize($this->tokenMock->reveal(), 'json', ['groups' => ['foo']]) - ->willReturn(['foo' => 'bar']) - ->shouldBeCalledOnce(); - $controller = new GetToken($this->normalizerMock->reveal()); - $response = $controller($this->tokenMock->reveal(), $this->providerMock->reveal()); + $this->providerMock->expects($this->once())->method('getPasswordTokenSerializationGroups')->willReturn(['foo']); + $this->normalizerMock->expects($this->once())->method('normalize')->with($this->tokenMock, 'json', ['groups' => ['foo']])->willReturn(['foo' => 'bar']); + $controller = new GetToken($this->normalizerMock); + $response = $controller($this->tokenMock, $this->providerMock); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals(json_encode(['foo' => 'bar']), $response->getContent()); } diff --git a/tests/Controller/ResetPasswordTest.php b/tests/Controller/ResetPasswordTest.php index 2d22912..df1330e 100755 --- a/tests/Controller/ResetPasswordTest.php +++ b/tests/Controller/ResetPasswordTest.php @@ -16,7 +16,6 @@ use CoopTilleuls\ForgotPasswordBundle\Controller\ResetPassword; use CoopTilleuls\ForgotPasswordBundle\Manager\ForgotPasswordManager; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\HttpFoundation\Response; @@ -26,9 +25,7 @@ */ final class ResetPasswordTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; @@ -39,15 +36,15 @@ final class ResetPasswordTest extends TestCase protected function setUp(): void { - $this->providerMock = $this->prophesize(ProviderInterface::class); - $this->managerMock = $this->prophesize(ForgotPasswordManager::class); + $this->providerMock = $this->createMock(ProviderInterface::class); + $this->managerMock = $this->createMock(ForgotPasswordManager::class); } public function testResetPasswordAction(): void { - $this->managerMock->resetPassword('email', 'foo@example.com', $this->providerMock)->shouldBeCalledOnce(); - $controller = new ResetPassword($this->managerMock->reveal()); - $response = $controller('email', 'foo@example.com', $this->providerMock->reveal()); + $this->managerMock->expects($this->once())->method('resetPassword')->with('email', 'foo@example.com', $this->providerMock); + $controller = new ResetPassword($this->managerMock); + $response = $controller('email', 'foo@example.com', $this->providerMock); $this->assertInstanceOf(Response::class, $response); $this->assertEquals('', $response->getContent()); $this->assertEquals(204, $response->getStatusCode()); diff --git a/tests/Controller/UpdatePasswordTest.php b/tests/Controller/UpdatePasswordTest.php index b8d2015..6fdacdb 100755 --- a/tests/Controller/UpdatePasswordTest.php +++ b/tests/Controller/UpdatePasswordTest.php @@ -17,7 +17,6 @@ use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken; use CoopTilleuls\ForgotPasswordBundle\Manager\ForgotPasswordManager; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\HttpFoundation\Response; @@ -27,9 +26,7 @@ */ final class UpdatePasswordTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; @@ -45,9 +42,9 @@ final class UpdatePasswordTest extends TestCase protected function setUp(): void { - $this->providerMock = $this->prophesize(ProviderInterface::class); - $this->managerMock = $this->prophesize(ForgotPasswordManager::class); - $this->tokenMock = $this->prophesize(AbstractPasswordToken::class); + $this->providerMock = $this->createMock(ProviderInterface::class); + $this->managerMock = $this->createMock(ForgotPasswordManager::class); + $this->tokenMock = $this->createMock(AbstractPasswordToken::class); } public function testUpdatePasswordAction(): void @@ -55,9 +52,9 @@ public function testUpdatePasswordAction(): void $expiredAt = new \DateTime('+1 day'); $expiredAt->setTime((int) $expiredAt->format('H'), (int) $expiredAt->format('m'), (int) $expiredAt->format('s'), 0); - $this->managerMock->updatePassword($this->tokenMock->reveal(), 'bar', $this->providerMock)->shouldBeCalledOnce(); - $controller = new UpdatePassword($this->managerMock->reveal()); - $response = $controller($this->tokenMock->reveal(), 'bar', $this->providerMock->reveal()); + $this->managerMock->expects($this->once())->method('updatePassword')->with($this->tokenMock, 'bar', $this->providerMock); + $controller = new UpdatePassword($this->managerMock); + $response = $controller($this->tokenMock, 'bar', $this->providerMock); $this->assertInstanceOf(Response::class, $response); $this->assertEquals('', $response->getContent()); $this->assertEquals(204, $response->getStatusCode()); diff --git a/tests/EventListener/ExceptionEventListenerTest.php b/tests/EventListener/ExceptionEventListenerTest.php index 3ead5fc..add5d30 100755 --- a/tests/EventListener/ExceptionEventListenerTest.php +++ b/tests/EventListener/ExceptionEventListenerTest.php @@ -15,9 +15,7 @@ use CoopTilleuls\ForgotPasswordBundle\EventListener\ExceptionEventListener; use CoopTilleuls\ForgotPasswordBundle\Exception\MissingFieldHttpException; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -27,48 +25,46 @@ */ final class ExceptionEventListenerTest extends TestCase { - use ProphecyTrait; - - public function testOnKernelExceptionInvalid(): void + public function testOnKernelExceptionInvalid(): void { if (class_exists(ExceptionEvent::class)) { - $eventMock = $this->prophesize(ExceptionEvent::class); - $eventMock->getThrowable()->willReturn($this->prophesize(\Exception::class)->reveal())->shouldBeCalledOnce(); + $eventMock = $this->createMock(ExceptionEvent::class); + $eventMock->expects($this->once())->method('getThrowable')->willReturn($this->createMock(\Exception::class)); } else { - $eventMock = $this->prophesize(GetResponseForExceptionEvent::class); - $eventMock->getException()->willReturn($this->prophesize(\Exception::class)->reveal())->shouldBeCalledOnce(); + $eventMock = $this->createMock(GetResponseForExceptionEvent::class); + $eventMock->expects($this->once())->method('getException')->willReturn($this->createMock(\Exception::class)); } if (method_exists(ExceptionEvent::class, 'isMainRequest')) { - $eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $eventMock->setResponse(Argument::any())->shouldNotBeCalled(); + $eventMock->expects($this->never())->method('setResponse'); $listener = new ExceptionEventListener(); - $listener->onKernelException($eventMock->reveal()); + $listener->onKernelException($eventMock); } public function testOnKernelExceptionSubRequest(): void { if (class_exists(ExceptionEvent::class)) { - $eventMock = $this->prophesize(ExceptionEvent::class); - $eventMock->getThrowable()->willReturn($this->prophesize(\Exception::class)->reveal())->shouldBeCalledOnce(); + $eventMock = $this->createMock(ExceptionEvent::class); + $eventMock->expects($this->once())->method('getThrowable')->willReturn($this->createMock(\Exception::class)); } else { - $eventMock = $this->prophesize(GetResponseForExceptionEvent::class); - $eventMock->getException()->willReturn($this->prophesize(\Exception::class)->reveal())->shouldBeCalledOnce(); + $eventMock = $this->createMock(GetResponseForExceptionEvent::class); + $eventMock->expects($this->once())->method('getException')->willReturn($this->createMock(\Exception::class)); } if (method_exists(ExceptionEvent::class, 'isMainRequest')) { - $eventMock->isMainRequest()->willReturn(false)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMainRequest')->willReturn(false); } else { - $eventMock->isMasterRequest()->willReturn(false)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMasterRequest')->willReturn(false); } - $eventMock->setResponse(Argument::any())->shouldNotBeCalled(); + $eventMock->expects($this->never())->method('setResponse'); $listener = new ExceptionEventListener(); - $listener->onKernelException($eventMock->reveal()); + $listener->onKernelException($eventMock); } public function testOnKernelException(): void @@ -78,31 +74,27 @@ public function testOnKernelException(): void $exception = new MissingFieldHttpException('foo'); if (class_exists(ExceptionEvent::class)) { - $eventMock = $this->prophesize(ExceptionEvent::class); - $eventMock->getThrowable()->willReturn($exception)->shouldBeCalledOnce(); + $eventMock = $this->createMock(ExceptionEvent::class); + $eventMock->expects($this->once())->method('getThrowable')->willReturn($exception); } else { - $eventMock = $this->prophesize(GetResponseForExceptionEvent::class); - $eventMock->getException()->willReturn($exception)->shouldBeCalledOnce(); + $eventMock = $this->createMock(GetResponseForExceptionEvent::class); + $eventMock->expects($this->once())->method('getException')->willReturn($exception); } if (method_exists(ExceptionEvent::class, 'isMainRequest')) { - $eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $eventMock->setResponse( - Argument::that( - function ($response) { - return $response instanceof JsonResponse - && json_encode( - ['message' => 'Parameter "foo" is missing.'], - 15 - ) === $response->getContent() - && 400 === $response->getStatusCode(); - } - ) - )->shouldBeCalledOnce(); + $eventMock->expects($this->once())->method('setResponse')->with($this->callback(function ($response) { + return $response instanceof JsonResponse + && json_encode( + ['message' => 'Parameter "foo" is missing.'], + 15 + ) === $response->getContent() + && 400 === $response->getStatusCode(); + })); $listener = new ExceptionEventListener(); - $listener->onKernelException($eventMock->reveal()); + $listener->onKernelException($eventMock); } } diff --git a/tests/EventListener/RequestEventListenerTest.php b/tests/EventListener/RequestEventListenerTest.php index 6f42ce7..23642e1 100755 --- a/tests/EventListener/RequestEventListenerTest.php +++ b/tests/EventListener/RequestEventListenerTest.php @@ -22,7 +22,6 @@ use CoopTilleuls\ForgotPasswordBundle\Manager\PasswordTokenManager; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderChainInterface; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\InputBag; @@ -36,9 +35,7 @@ */ final class RequestEventListenerTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var RequestEventListener */ private $listener; @@ -53,37 +50,37 @@ final class RequestEventListenerTest extends TestCase protected function setUp(): void { - $this->providerMock = $this->prophesize(ProviderInterface::class); - $this->passwordTokenManagerMock = $this->prophesize(PasswordTokenManager::class); - $this->eventMock = $this->prophesize(KernelEvent::class); - $this->requestMock = $this->prophesize(Request::class); - $this->parameterBagMock = $this->prophesize(ParameterBag::class); - $this->headerBagMock = $this->prophesize(HeaderBag::class); - $this->providerChainMock = $this->prophesize(ProviderChainInterface::class); - $this->inputBagMock = $this->prophesize(InputBag::class); - - $this->eventMock->getRequest()->willReturn($this->requestMock->reveal())->shouldBeCalledOnce(); - $this->requestMock->attributes = $this->parameterBagMock->reveal(); - $this->requestMock->query = $this->inputBagMock->reveal(); - $this->requestMock->headers = $this->headerBagMock->reveal(); + $this->providerMock = $this->createMock(ProviderInterface::class); + $this->passwordTokenManagerMock = $this->createMock(PasswordTokenManager::class); + $this->eventMock = $this->createMock(KernelEvent::class); + $this->requestMock = $this->createMock(Request::class); + $this->parameterBagMock = $this->createMock(ParameterBag::class); + $this->headerBagMock = $this->createMock(HeaderBag::class); + $this->providerChainMock = $this->createMock(ProviderChainInterface::class); + $this->inputBagMock = $this->createMock(InputBag::class); + + $this->eventMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->requestMock->attributes = $this->parameterBagMock; + $this->requestMock->query = $this->inputBagMock; + $this->requestMock->headers = $this->headerBagMock; $this->listener = new RequestEventListener( - $this->passwordTokenManagerMock->reveal(), - $this->providerChainMock->reveal() + $this->passwordTokenManagerMock, + $this->providerChainMock ); } public function testDecodeRequestInvalidRoute(): void { - $this->parameterBagMock->get('_route')->willReturn('foo')->shouldBeCalledOnce(); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('foo'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->shouldNotBeCalled(); + $this->requestMock->expects($this->never())->method('getContent'); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testDecodeRequestMissingFieldException(): void @@ -91,15 +88,15 @@ public function testDecodeRequestMissingFieldException(): void $this->expectException(MissingFieldHttpException::class); $this->expectExceptionMessage('Parameter "password" is missing.'); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('coop_tilleuls_forgot_password.update'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->willReturn(json_encode(['password' => '']))->shouldBeCalledOnce(); + $this->requestMock->expects($this->once())->method('getContent')->willReturn(json_encode(['password' => ''])); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testDecodeRequestNoParametersException(): void @@ -107,15 +104,15 @@ public function testDecodeRequestNoParametersException(): void $this->expectException(NoParameterException::class); $this->expectExceptionMessage('No parameter sent.'); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('coop_tilleuls_forgot_password.update'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->willReturn('{}')->shouldBeCalledOnce(); + $this->requestMock->expects($this->once())->method('getContent')->willReturn('{}'); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testDecodeRequestInvalidJsonHttpException(): void @@ -123,16 +120,16 @@ public function testDecodeRequestInvalidJsonHttpException(): void $this->expectException(InvalidJsonHttpException::class); $this->expectExceptionMessage('Invalid JSON data.'); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('coop_tilleuls_forgot_password.update'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->willReturn('{')->shouldBeCalledOnce(); + $this->requestMock->expects($this->once())->method('getContent')->willReturn('{'); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testDecodeRequestUnauthorizedException(): void @@ -140,114 +137,109 @@ public function testDecodeRequestUnauthorizedException(): void $this->expectException(UnauthorizedFieldException::class); $this->expectExceptionMessage('The parameter "name" is not authorized in your configuration.'); - $this->headerBagMock->get('FP-provider')->shouldBeCalledOnce()->willReturn('user'); - $this->providerChainMock->get('user')->shouldBeCalledOnce()->willReturn($this->providerMock); - $this->providerMock->getUserAuthorizedFields()->shouldBeCalledOnce()->willReturn(['username', 'email']); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.reset')->shouldBeCalledOnce(); - $this->parameterBagMock->set('provider', $this->providerMock)->shouldBeCalledOnce(); + $this->headerBagMock->expects($this->once())->method('get')->with('FP-provider')->willReturn('user'); + $this->providerChainMock->expects($this->once())->method('get')->with('user')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getUserAuthorizedFields')->willReturn(['username', 'email']); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('coop_tilleuls_forgot_password.reset'); + $this->parameterBagMock->expects($this->once())->method('set')->with('provider', $this->providerMock); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->willReturn(json_encode(['name' => 'foo']))->shouldBeCalledOnce(); + $this->requestMock->expects($this->once())->method('getContent')->willReturn(json_encode(['name' => 'foo'])); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testDecodeRequest(): void { - $this->headerBagMock->get('FP-provider')->shouldBeCalledOnce()->willReturn('user'); - $this->providerChainMock->get('user')->shouldBeCalledOnce()->willReturn($this->providerMock); - $this->providerMock->getUserAuthorizedFields()->shouldNotBeCalled(); - $this->providerMock->getUserPasswordField()->shouldBeCalledOnce()->willReturn('password'); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); - $this->parameterBagMock->set('provider', $this->providerMock)->shouldBeCalledOnce(); + $this->headerBagMock->expects($this->once())->method('get')->with('FP-provider')->willReturn('user'); + $this->providerChainMock->expects($this->once())->method('get')->with('user')->willReturn($this->providerMock); + $this->providerMock->expects($this->never())->method('getUserAuthorizedFields'); + $this->providerMock->expects($this->once())->method('getUserPasswordField')->willReturn('password'); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('coop_tilleuls_forgot_password.update'); + $this->parameterBagMock->expects($this->exactly(2))->method('set')->withConsecutive(['provider', $this->providerMock], ['password', 'bar']); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->willReturn(json_encode(['password' => 'bar']))->shouldBeCalledOnce(); - $this->parameterBagMock->set('password', 'bar')->shouldBeCalledOnce(); + $this->requestMock->expects($this->once())->method('getContent')->willReturn(json_encode(['password' => 'bar'])); - $this->listener->decodeRequest($this->eventMock->reveal()); + $this->listener->decodeRequest($this->eventMock); } public function testGetTokenFromRequestInvalidRoute(): void { - $this->parameterBagMock->get('_route')->willReturn('foo')->shouldBeCalledOnce(); + $this->parameterBagMock->expects($this->once())->method('get')->with('_route')->willReturn('foo'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->requestMock->getContent()->shouldNotBeCalled(); + $this->requestMock->expects($this->never())->method('getContent'); - $this->listener->getTokenFromRequest($this->eventMock->reveal()); + $this->listener->getTokenFromRequest($this->eventMock); } public function testGetTokenFromRequestNoTokenException(): void { $this->expectException(NotFoundHttpException::class); - $this->headerBagMock->get('FP-provider')->shouldBeCalledOnce()->willReturn('admin'); - $this->providerChainMock->get('admin')->shouldBeCalledOnce()->willReturn($this->providerMock); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); + $this->headerBagMock->expects($this->once())->method('get')->with('FP-provider')->willReturn('admin'); + $this->providerChainMock->expects($this->once())->method('get')->with('admin')->willReturn($this->providerMock); + $this->parameterBagMock->expects($this->exactly(2))->method('get')->withConsecutive(['_route'], ['tokenValue'])->willReturnOnConsecutiveCalls('coop_tilleuls_forgot_password.update', 'foo'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->parameterBagMock->get('tokenValue')->willReturn('foo')->shouldBeCalledOnce(); - $this->passwordTokenManagerMock->findOneByToken('foo', $this->providerMock->reveal())->shouldBeCalledOnce(); + $this->passwordTokenManagerMock->expects($this->once())->method('findOneByToken')->with('foo', $this->providerMock); - $this->listener->getTokenFromRequest($this->eventMock->reveal()); + $this->listener->getTokenFromRequest($this->eventMock); } public function testGetTokenFromRequestInvalidTokenException(): void { $this->expectException(NotFoundHttpException::class); - $tokenMock = $this->prophesize(AbstractPasswordToken::class); + $tokenMock = $this->createMock(AbstractPasswordToken::class); - $this->headerBagMock->get('FP-provider')->shouldBeCalledOnce()->willReturn('admin'); - $this->providerChainMock->get('admin')->shouldBeCalledOnce()->willReturn($this->providerMock); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); + $this->headerBagMock->expects($this->once())->method('get')->with('FP-provider')->willReturn('admin'); + $this->providerChainMock->expects($this->once())->method('get')->with('admin')->willReturn($this->providerMock); + $this->parameterBagMock->expects($this->exactly(2))->method('get')->withConsecutive(['_route'], ['tokenValue'])->willReturnOnConsecutiveCalls('coop_tilleuls_forgot_password.update', 'foo'); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->parameterBagMock->get('tokenValue')->willReturn('foo')->shouldBeCalledOnce(); - $this->passwordTokenManagerMock->findOneByToken('foo', $this->providerMock->reveal())->willReturn($tokenMock->reveal())->shouldBeCalledOnce(); - $tokenMock->isExpired()->willReturn(true)->shouldBeCalledOnce(); + $this->passwordTokenManagerMock->expects($this->once())->method('findOneByToken')->with('foo', $this->providerMock)->willReturn($tokenMock); + $tokenMock->expects($this->once())->method('isExpired')->willReturn(true); - $this->listener->getTokenFromRequest($this->eventMock->reveal()); + $this->listener->getTokenFromRequest($this->eventMock); } public function testGetTokenFromRequest(): void { - $tokenMock = $this->prophesize(AbstractPasswordToken::class); - $this->headerBagMock->get('FP-provider')->shouldBeCalledOnce()->willReturn('user'); - $this->providerChainMock->get('user')->shouldBeCalledOnce()->willReturn($this->providerMock); - $this->parameterBagMock->get('_route')->willReturn('coop_tilleuls_forgot_password.update')->shouldBeCalledOnce(); - $this->parameterBagMock->set('provider', $this->providerMock)->shouldBeCalledOnce(); + $tokenMock = $this->createMock(AbstractPasswordToken::class); + $this->headerBagMock->expects($this->once())->method('get')->with('FP-provider')->willReturn('user'); + $this->providerChainMock->expects($this->once())->method('get')->with('user')->willReturn($this->providerMock); + $this->parameterBagMock->expects($this->exactly(2))->method('get')->withConsecutive(['_route'], ['tokenValue'])->willReturnOnConsecutiveCalls('coop_tilleuls_forgot_password.update', 'foo'); + $this->parameterBagMock->expects($this->exactly(2))->method('set')->withConsecutive(['token', $tokenMock], ['provider', $this->providerMock]); if (method_exists(KernelEvent::class, 'isMainRequest')) { - $this->eventMock->isMainRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMainRequest')->willReturn(true); } else { - $this->eventMock->isMasterRequest()->willReturn(true)->shouldBeCalledOnce(); + $this->eventMock->expects($this->once())->method('isMasterRequest')->willReturn(true); } - $this->parameterBagMock->get('tokenValue')->willReturn('foo')->shouldBeCalledOnce(); - $this->passwordTokenManagerMock->findOneByToken('foo', $this->providerMock->reveal())->willReturn($tokenMock->reveal())->shouldBeCalledOnce(); - $tokenMock->isExpired()->willReturn(false)->shouldBeCalledOnce(); - $this->parameterBagMock->set('token', $tokenMock->reveal())->shouldBeCalledOnce(); + $this->passwordTokenManagerMock->expects($this->once())->method('findOneByToken')->with('foo', $this->providerMock)->willReturn($tokenMock); + $tokenMock->expects($this->once())->method('isExpired')->willReturn(false); - $this->listener->getTokenFromRequest($this->eventMock->reveal()); + $this->listener->getTokenFromRequest($this->eventMock); } } diff --git a/tests/Manager/Bridge/DoctrineManagerTest.php b/tests/Manager/Bridge/DoctrineManagerTest.php index f1fcf5c..1ab0bf2 100755 --- a/tests/Manager/Bridge/DoctrineManagerTest.php +++ b/tests/Manager/Bridge/DoctrineManagerTest.php @@ -14,7 +14,6 @@ namespace CoopTilleuls\ForgotPasswordBundle\Tests\Manager\Bridge; use CoopTilleuls\ForgotPasswordBundle\Manager\Bridge\DoctrineManager; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use Doctrine\Bundle\DoctrineBundle\Registry; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; @@ -25,9 +24,7 @@ */ final class DoctrineManagerTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var DoctrineManager */ private $doctrineManager; @@ -38,38 +35,38 @@ final class DoctrineManagerTest extends TestCase protected function setUp(): void { - $this->registryMock = $this->prophesize(Registry::class); - $this->managerMock = $this->prophesize(EntityManagerInterface::class); - $this->repositoryMock = $this->prophesize(EntityRepository::class); - $this->objectMock = $this->prophesize(\stdClass::class); + $this->registryMock = $this->createMock(Registry::class); + $this->managerMock = $this->createMock(EntityManagerInterface::class); + $this->repositoryMock = $this->createMock(EntityRepository::class); + $this->objectMock = $this->createMock(\stdClass::class); - $this->doctrineManager = new DoctrineManager($this->registryMock->reveal()); + $this->doctrineManager = new DoctrineManager($this->registryMock); } public function testFindOneBy(): void { - $this->registryMock->getManagerForClass('class')->willReturn($this->managerMock->reveal())->shouldBeCalledOnce(); - $this->managerMock->getRepository('class')->willReturn($this->repositoryMock->reveal())->shouldBeCalledOnce(); - $this->repositoryMock->findOneBy(['criteria'])->willReturn('foo')->shouldBeCalledOnce(); + $this->registryMock->expects($this->once())->method('getManagerForClass')->with('class')->willReturn($this->managerMock); + $this->managerMock->expects($this->once())->method('getRepository')->with('class')->willReturn($this->repositoryMock); + $this->repositoryMock->expects($this->once())->method('findOneBy')->with(['criteria'])->willReturn('foo'); $this->assertEquals('foo', $this->doctrineManager->findOneBy('class', ['criteria'])); } public function testPersist(): void { - $this->registryMock->getManagerForClass(\get_class($this->objectMock->reveal()))->willReturn($this->managerMock->reveal())->shouldBeCalledOnce(); - $this->managerMock->persist($this->objectMock->reveal())->shouldBeCalledOnce(); - $this->managerMock->flush()->shouldBeCalledOnce(); + $this->registryMock->expects($this->once())->method('getManagerForClass')->with(\get_class($this->objectMock))->willReturn($this->managerMock); + $this->managerMock->expects($this->once())->method('persist')->with($this->objectMock); + $this->managerMock->expects($this->once())->method('flush'); - $this->doctrineManager->persist($this->objectMock->reveal()); + $this->doctrineManager->persist($this->objectMock); } public function testRemove(): void { - $this->registryMock->getManagerForClass(\get_class($this->objectMock->reveal()))->willReturn($this->managerMock->reveal())->shouldBeCalledOnce(); - $this->managerMock->remove($this->objectMock->reveal())->shouldBeCalledOnce(); - $this->managerMock->flush()->shouldBeCalledOnce(); + $this->registryMock->expects($this->once())->method('getManagerForClass')->with(\get_class($this->objectMock))->willReturn($this->managerMock); + $this->managerMock->expects($this->once())->method('remove')->with($this->objectMock); + $this->managerMock->expects($this->once())->method('flush'); - $this->doctrineManager->remove($this->objectMock->reveal()); + $this->doctrineManager->remove($this->objectMock); } } diff --git a/tests/Manager/ForgotPasswordManagerTest.php b/tests/Manager/ForgotPasswordManagerTest.php index a6e811b..1ec02f8 100755 --- a/tests/Manager/ForgotPasswordManagerTest.php +++ b/tests/Manager/ForgotPasswordManagerTest.php @@ -24,9 +24,7 @@ use CoopTilleuls\ForgotPasswordBundle\Manager\PasswordTokenManager; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderChainInterface; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface; @@ -36,9 +34,7 @@ */ final class ForgotPasswordManagerTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var ForgotPasswordManager */ private $manager; @@ -53,61 +49,61 @@ final class ForgotPasswordManagerTest extends TestCase protected function setUp(): void { - $this->passwordManagerMock = $this->prophesize(PasswordTokenManager::class); - $this->eventDispatcherMock = $this->prophesize(EventDispatcherInterface::class); - $this->managerMock = $this->prophesize(ManagerInterface::class); - $this->userMock = $this->prophesize(UserInterface::class); - $this->tokenMock = $this->prophesize(AbstractPasswordToken::class); - $this->countableMock = $this->prophesize(\Countable::class); - $this->providerChainMock = $this->prophesize(ProviderChainInterface::class); - $this->providerMock = $this->prophesize(ProviderInterface::class); + $this->passwordManagerMock = $this->createMock(PasswordTokenManager::class); + $this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); + $this->managerMock = $this->createMock(ManagerInterface::class); + $this->userMock = $this->createMock(UserInterface::class); + $this->tokenMock = $this->createMock(AbstractPasswordToken::class); + $this->countableMock = $this->createMock(\Countable::class); + $this->providerChainMock = $this->createMock(ProviderChainInterface::class); + $this->providerMock = $this->createMock(ProviderInterface::class); $this->manager = new ForgotPasswordManager( - $this->passwordManagerMock->reveal(), - $this->eventDispatcherMock->reveal(), - $this->providerChainMock->reveal() + $this->passwordManagerMock, + $this->eventDispatcherMock, + $this->providerChainMock ); } public function testResetPasswordNotUser(): void { - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); - $this->providerMock->getUserClass()->willReturn(User::class)->shouldBeCalledOnce(); - $this->managerMock->findOneBy(User::class, ['email' => 'foo@example.com'])->shouldBeCalledOnce(); - if ($this->eventDispatcherMock->reveal() instanceof ContractsEventDispatcherInterface) { - $this->eventDispatcherMock->dispatch(Argument::that(function ($event) { + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); + $this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); + $this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => 'foo@example.com']); + if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with($this->callback(function ($event) { return $event instanceof UserNotFoundEvent && ['email' => 'foo@example.com'] === $event->getContext(); - }))->shouldBeCalledOnce(); + })); } else { - $this->eventDispatcherMock->dispatch(UserNotFoundEvent::USER_NOT_FOUND, Argument::that(function ($event) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(UserNotFoundEvent::USER_NOT_FOUND, $this->callback(function ($event) { return $event instanceof UserNotFoundEvent && ['email' => 'foo@example.com'] === $event->getContext(); - }))->shouldBeCalledOnce(); + })); } - $this->passwordManagerMock->findOneByUser(Argument::any(), $this->providerMock->reveal())->shouldNotBeCalled(); + $this->passwordManagerMock->expects($this->never())->method('findOneByUser')->with(self::any(), $this->providerMock); $this->manager->resetPassword('email', 'foo@example.com'); } public function testResetPasswordWithNoPreviousToken(): void { - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); - $this->providerMock->getUserClass()->willReturn(User::class)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenExpiredIn()->willReturn('+1 day')->shouldBeCalledOnce(); - $this->managerMock->findOneBy(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock->reveal())->shouldBeCalledOnce(); - $this->passwordManagerMock->findOneByUser($this->userMock->reveal(), $this->providerMock)->willReturn(null)->shouldBeCalledOnce(); - $this->passwordManagerMock->createPasswordToken($this->userMock->reveal(), Argument::type(\DateTimeInterface::class), $this->providerMock)->willReturn($this->tokenMock->reveal())->shouldBeCalledOnce(); - - if ($this->eventDispatcherMock->reveal() instanceof ContractsEventDispatcherInterface) { - $this->eventDispatcherMock->dispatch(Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); + $this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); + $this->providerMock->expects($this->once())->method('getPasswordTokenExpiredIn')->willReturn('+1 day'); + $this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock); + $this->passwordManagerMock->expects($this->once())->method('findOneByUser')->with($this->userMock, $this->providerMock)->willReturn(null); + $this->passwordManagerMock->expects($this->once())->method('createPasswordToken')->with($this->userMock, $this->isInstanceOf(\DateTimeInterface::class), $this->providerMock)->willReturn($this->tokenMock); + + if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with($this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } else { - $this->eventDispatcherMock->dispatch(ForgotPasswordEvent::CREATE_TOKEN, Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } $this->manager->resetPassword('email', 'foo@example.com'); @@ -115,23 +111,23 @@ public function testResetPasswordWithNoPreviousToken(): void public function testResetPasswordWithExpiredPreviousToken(): void { - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); - $this->providerMock->getUserClass()->willReturn(User::class)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenExpiredIn()->willReturn('+1 day')->shouldBeCalledOnce(); - $this->tokenMock->isExpired()->willReturn(true)->shouldBeCalledOnce(); - $this->managerMock->findOneBy(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock->reveal())->shouldBeCalledOnce(); - $this->passwordManagerMock->findOneByUser($this->userMock->reveal(), $this->providerMock)->willReturn($this->tokenMock->reveal())->shouldBeCalledOnce(); - $this->passwordManagerMock->createPasswordToken($this->userMock->reveal(), Argument::type(\DateTimeInterface::class), $this->providerMock)->willReturn($this->tokenMock->reveal())->shouldBeCalledOnce(); - - if ($this->eventDispatcherMock->reveal() instanceof ContractsEventDispatcherInterface) { - $this->eventDispatcherMock->dispatch(Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); + $this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); + $this->providerMock->expects($this->once())->method('getPasswordTokenExpiredIn')->willReturn('+1 day'); + $this->tokenMock->expects($this->once())->method('isExpired')->willReturn(true); + $this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock); + $this->passwordManagerMock->expects($this->once())->method('findOneByUser')->with($this->userMock, $this->providerMock)->willReturn($this->tokenMock); + $this->passwordManagerMock->expects($this->once())->method('createPasswordToken')->with($this->userMock, $this->isInstanceOf(\DateTimeInterface::class), $this->providerMock)->willReturn($this->tokenMock); + + if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with($this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } else { - $this->eventDispatcherMock->dispatch(ForgotPasswordEvent::CREATE_TOKEN, Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } $this->manager->resetPassword('email', 'foo@example.com'); @@ -142,22 +138,22 @@ public function testResetPasswordWithExpiredPreviousToken(): void */ public function testResetPasswordWithUnexpiredTokenHttp(): void { - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); - $this->providerMock->getUserClass()->willReturn(User::class)->shouldBeCalledOnce(); - $this->tokenMock->isExpired()->willReturn(false)->shouldBeCalledOnce(); - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->managerMock->findOneBy(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock->reveal())->shouldBeCalledOnce(); - $this->passwordManagerMock->findOneByUser($this->userMock->reveal(), $this->providerMock)->willReturn($this->tokenMock->reveal())->shouldBeCalledOnce(); - - if ($this->eventDispatcherMock->reveal() instanceof ContractsEventDispatcherInterface) { - $this->eventDispatcherMock->dispatch(Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); + $this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); + $this->tokenMock->expects($this->once())->method('isExpired')->willReturn(false); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => 'foo@example.com'])->willReturn($this->userMock); + $this->passwordManagerMock->expects($this->once())->method('findOneByUser')->with($this->userMock, $this->providerMock)->willReturn($this->tokenMock); + + if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with($this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } else { - $this->eventDispatcherMock->dispatch(ForgotPasswordEvent::CREATE_TOKEN, Argument::that(function ($event) { - return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(function ($event) { + return $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } $this->manager->resetPassword('email', 'foo@example.com'); @@ -165,20 +161,20 @@ public function testResetPasswordWithUnexpiredTokenHttp(): void public function testUpdatePassword(): void { - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); - if ($this->eventDispatcherMock->reveal() instanceof ContractsEventDispatcherInterface) { - $this->eventDispatcherMock->dispatch(Argument::that(function ($event) { - return $event instanceof UpdatePasswordEvent && 'bar' === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with($this->callback(function ($event) { + return $event instanceof UpdatePasswordEvent && 'bar' === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } else { - $this->eventDispatcherMock->dispatch(ForgotPasswordEvent::UPDATE_PASSWORD, Argument::that(function ($event) { - return $event instanceof UpdatePasswordEvent && 'bar' === $event->getPassword() && $this->tokenMock->reveal() === $event->getPasswordToken(); - }))->shouldBeCalledOnce(); + $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::UPDATE_PASSWORD, $this->callback(function ($event) { + return $event instanceof UpdatePasswordEvent && 'bar' === $event->getPassword() && $this->tokenMock === $event->getPasswordToken(); + })); } - $this->managerMock->remove($this->tokenMock)->shouldBeCalledOnce(); + $this->managerMock->expects($this->once())->method('remove')->with($this->tokenMock); - $this->manager->updatePassword($this->tokenMock->reveal(), 'bar'); + $this->manager->updatePassword($this->tokenMock, 'bar'); } } diff --git a/tests/Manager/PasswordTokenManagerTest.php b/tests/Manager/PasswordTokenManagerTest.php index 2186a72..b965da9 100755 --- a/tests/Manager/PasswordTokenManagerTest.php +++ b/tests/Manager/PasswordTokenManagerTest.php @@ -18,9 +18,7 @@ use CoopTilleuls\ForgotPasswordBundle\Manager\PasswordTokenManager; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderChainInterface; use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; use Symfony\Component\Security\Core\User\UserInterface; /** @@ -28,9 +26,7 @@ */ final class PasswordTokenManagerTest extends TestCase { - use ProphecyTrait; - - /** + /** * @var PasswordTokenManager */ private $manager; @@ -42,52 +38,52 @@ final class PasswordTokenManagerTest extends TestCase protected function setUp(): void { - $this->managerMock = $this->prophesize(ManagerInterface::class); - $this->userMock = $this->prophesize(UserInterface::class); - $this->tokenMock = $this->prophesize(AbstractPasswordToken::class); - $this->providerChainMock = $this->prophesize(ProviderChainInterface::class); - $this->providerMock = $this->prophesize(ProviderInterface::class); + $this->managerMock = $this->createMock(ManagerInterface::class); + $this->userMock = $this->createMock(UserInterface::class); + $this->tokenMock = $this->createMock(AbstractPasswordToken::class); + $this->providerChainMock = $this->createMock(ProviderChainInterface::class); + $this->providerMock = $this->createMock(ProviderInterface::class); - $this->manager = new PasswordTokenManager($this->providerChainMock->reveal()); + $this->manager = new PasswordTokenManager($this->providerChainMock); } public function testCreatePasswordToken(): void { - $this->managerMock->persist(Argument::that(function ($object) { + $this->managerMock->expects($this->once())->method('persist')->with($this->callback(function ($object) { return $object instanceof AbstractPasswordToken && '2016-10-11 10:00:00' === $object->getExpiresAt()->format('Y-m-d H:i:s') && preg_match('/^[A-z\d]{50}$/', $object->getToken()) - && $this->userMock->reveal() === $object->getUser(); - }))->shouldBeCalledOnce(); + && $this->userMock === $object->getUser(); + })); - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenClass()->willReturn(PasswordToken::class)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getPasswordTokenClass')->willReturn(PasswordToken::class); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); - $this->manager->createPasswordToken($this->userMock->reveal(), new \DateTime('2016-10-11 10:00:00')); + $this->manager->createPasswordToken($this->userMock, new \DateTime('2016-10-11 10:00:00')); } public function testFindOneByToken(): void { - $this->managerMock->findOneBy(PasswordToken::class, ['token' => 'foo'])->willReturn('bar')->shouldBeCalledOnce(); + $this->managerMock->expects($this->once())->method('findOneBy')->with(PasswordToken::class, ['token' => 'foo'])->willReturn('bar'); - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenClass()->willReturn(PasswordToken::class)->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getPasswordTokenClass')->willReturn(PasswordToken::class); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); $this->assertEquals('bar', $this->manager->findOneByToken('foo')); } public function testFindOneByUser(): void { - $this->managerMock->findOneBy(PasswordToken::class, ['user' => $this->userMock->reveal()])->willReturn('bar')->shouldBeCalledOnce(); + $this->managerMock->expects($this->once())->method('findOneBy')->with(PasswordToken::class, ['user' => $this->userMock])->willReturn('bar'); - $this->providerChainMock->get()->willReturn($this->providerMock)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenClass()->willReturn(PasswordToken::class)->shouldBeCalledOnce(); - $this->providerMock->getPasswordTokenUserField()->willReturn('user')->shouldBeCalledOnce(); - $this->providerMock->getManager()->willReturn($this->managerMock)->shouldBeCalledOnce(); + $this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); + $this->providerMock->expects($this->once())->method('getPasswordTokenClass')->willReturn(PasswordToken::class); + $this->providerMock->expects($this->once())->method('getPasswordTokenUserField')->willReturn('user'); + $this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); - $this->assertEquals('bar', $this->manager->findOneByUser($this->userMock->reveal())); + $this->assertEquals('bar', $this->manager->findOneByUser($this->userMock)); } } diff --git a/tests/Normalizer/JMSNormalizerTest.php b/tests/Normalizer/JMSNormalizerTest.php index 6593f49..f93481e 100644 --- a/tests/Normalizer/JMSNormalizerTest.php +++ b/tests/Normalizer/JMSNormalizerTest.php @@ -15,7 +15,6 @@ use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken; use CoopTilleuls\ForgotPasswordBundle\Normalizer\JMSNormalizer; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use JMS\Serializer\ArrayTransformerInterface; use PHPUnit\Framework\TestCase; @@ -24,16 +23,14 @@ */ final class JMSNormalizerTest extends TestCase { - use ProphecyTrait; - - public function testNormalize(): void + public function testNormalize(): void { - $normalizerMock = $this->prophesize(ArrayTransformerInterface::class); - $passwordTokenMock = $this->prophesize(AbstractPasswordToken::class); + $normalizerMock = $this->createMock(ArrayTransformerInterface::class); + $passwordTokenMock = $this->createMock(AbstractPasswordToken::class); - $normalizerMock->toArray($passwordTokenMock)->willReturn(['foo'])->shouldBeCalledOnce(); + $normalizerMock->expects($this->once())->method('toArray')->with($passwordTokenMock)->willReturn(['foo']); - $normalizer = new JMSNormalizer($normalizerMock->reveal()); - $this->assertEquals(['foo'], $normalizer->normalize($passwordTokenMock->reveal(), 'json')); + $normalizer = new JMSNormalizer($normalizerMock); + $this->assertEquals(['foo'], $normalizer->normalize($passwordTokenMock, 'json')); } } diff --git a/tests/Normalizer/SymfonyNormalizerTest.php b/tests/Normalizer/SymfonyNormalizerTest.php index 1d87289..953f2aa 100644 --- a/tests/Normalizer/SymfonyNormalizerTest.php +++ b/tests/Normalizer/SymfonyNormalizerTest.php @@ -15,7 +15,6 @@ use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken; use CoopTilleuls\ForgotPasswordBundle\Normalizer\SymfonyNormalizer; -use CoopTilleuls\ForgotPasswordBundle\Tests\ProphecyTrait; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -24,16 +23,14 @@ */ final class SymfonyNormalizerTest extends TestCase { - use ProphecyTrait; - - public function testNormalize(): void + public function testNormalize(): void { - $normalizerMock = $this->prophesize(NormalizerInterface::class); - $passwordTokenMock = $this->prophesize(AbstractPasswordToken::class); + $normalizerMock = $this->createMock(NormalizerInterface::class); + $passwordTokenMock = $this->createMock(AbstractPasswordToken::class); - $normalizerMock->normalize($passwordTokenMock, 'json', [])->willReturn('foo')->shouldBeCalledOnce(); + $normalizerMock->expects($this->once())->method('normalize')->with($passwordTokenMock, 'json', [])->willReturn('foo'); - $normalizer = new SymfonyNormalizer($normalizerMock->reveal()); - $this->assertEquals('foo', $normalizer->normalize($passwordTokenMock->reveal(), 'json')); + $normalizer = new SymfonyNormalizer($normalizerMock); + $this->assertEquals('foo', $normalizer->normalize($passwordTokenMock, 'json')); } } diff --git a/tests/ProphecyTrait.php b/tests/ProphecyTrait.php deleted file mode 100644 index 1f07442..0000000 --- a/tests/ProphecyTrait.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace CoopTilleuls\ForgotPasswordBundle\Tests; - -use PHPUnit\Framework\AssertionFailedError; -use PHPUnit\Framework\TestCase; -use Prophecy\Exception\Doubler\DoubleException; -use Prophecy\Exception\Doubler\InterfaceNotFoundException; -use Prophecy\Exception\Prediction\PredictionException; -use Prophecy\Prophecy\MethodProphecy; -use Prophecy\Prophecy\ObjectProphecy; -use Prophecy\Prophet; - -/** - * Copied from https://github.com/phpspec/prophecy-phpunit for symfony/phpunit-bridge. - * - * @mixin TestCase - */ -trait ProphecyTrait -{ - /** - * @var Prophet|null - * - * @internal - */ - private $prophet; - - /** - * @var bool - * - * @internal - */ - private $prophecyAssertionsCounted = false; - - /** - * @throws DoubleException - * @throws InterfaceNotFoundException - * - * @psalm-param class-string|null $classOrInterface - */ - protected function prophesize(string $classOrInterface = null): ObjectProphecy - { - if (\is_string($classOrInterface)) { - \assert($this instanceof TestCase); - $this->recordDoubledType($classOrInterface); - } - - return $this->getProphet()->prophesize($classOrInterface); - } - - /** - * @postCondition - */ - protected function verifyProphecyDoubles(): void - { - if (null === $this->prophet) { - return; - } - - try { - $this->prophet->checkPredictions(); - } catch (PredictionException $e) { - throw new AssertionFailedError($e->getMessage()); - } finally { - $this->countProphecyAssertions(); - } - } - - /** - * @after - */ - protected function tearDownProphecy(): void - { - if (null !== $this->prophet && !$this->prophecyAssertionsCounted) { - // Some Prophecy assertions may have been done in tests themselves even when a failure happened before checking mock objects. - $this->countProphecyAssertions(); - } - - $this->prophet = null; - } - - /** - * @internal - */ - private function countProphecyAssertions(): void - { - \assert($this instanceof TestCase); - $this->prophecyAssertionsCounted = true; - - foreach ($this->prophet->getProphecies() as $objectProphecy) { - foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) { - foreach ($methodProphecies as $methodProphecy) { - \assert($methodProphecy instanceof MethodProphecy); - - $this->addToAssertionCount(\count($methodProphecy->getCheckedPredictions())); - } - } - } - } - - /** - * @internal - */ - private function getProphet(): Prophet - { - if (null === $this->prophet) { - $this->prophet = new Prophet(); - } - - return $this->prophet; - } -} From 8433b118bb146bbfa90f2dcaed936650e3cca01e Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:07:06 +0100 Subject: [PATCH 2/2] fix: CS --- .github/workflows/ci.yml | 2 +- .../ApiPlatform/Serializer/DocumentationNormalizerTest.php | 2 +- tests/Controller/GetTokenTest.php | 2 +- tests/Controller/ResetPasswordTest.php | 2 +- tests/Controller/UpdatePasswordTest.php | 2 +- tests/EventListener/ExceptionEventListenerTest.php | 2 +- tests/EventListener/RequestEventListenerTest.php | 2 +- tests/Manager/Bridge/DoctrineManagerTest.php | 2 +- tests/Manager/ForgotPasswordManagerTest.php | 2 +- tests/Manager/PasswordTokenManagerTest.php | 2 +- tests/Normalizer/JMSNormalizerTest.php | 2 +- tests/Normalizer/SymfonyNormalizerTest.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 624e1ed..2704aa5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,7 @@ jobs: - name: Run php-cs-fixer tests if: matrix.quality env: - # PHP CS Fixer does not support PHP 8.2 yet + # PHP CS Fixer does not support PHP 8.3 yet PHP_CS_FIXER_IGNORE_ENV: 1 run: php-cs-fixer fix --diff --dry-run - name: Run PHPUnit tests diff --git a/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php b/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php index 246b435..32fb4ad 100755 --- a/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php +++ b/tests/Bridge/ApiPlatform/Serializer/DocumentationNormalizerTest.php @@ -28,7 +28,7 @@ */ final class DocumentationNormalizerTest extends TestCase { - /** + /** * @var NormalizerInterface|ObjectProphecy */ private $normalizerMock; diff --git a/tests/Controller/GetTokenTest.php b/tests/Controller/GetTokenTest.php index 68f26c6..183ba59 100755 --- a/tests/Controller/GetTokenTest.php +++ b/tests/Controller/GetTokenTest.php @@ -26,7 +26,7 @@ */ final class GetTokenTest extends TestCase { - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; diff --git a/tests/Controller/ResetPasswordTest.php b/tests/Controller/ResetPasswordTest.php index df1330e..3500afc 100755 --- a/tests/Controller/ResetPasswordTest.php +++ b/tests/Controller/ResetPasswordTest.php @@ -25,7 +25,7 @@ */ final class ResetPasswordTest extends TestCase { - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; diff --git a/tests/Controller/UpdatePasswordTest.php b/tests/Controller/UpdatePasswordTest.php index 6fdacdb..c159ad9 100755 --- a/tests/Controller/UpdatePasswordTest.php +++ b/tests/Controller/UpdatePasswordTest.php @@ -26,7 +26,7 @@ */ final class UpdatePasswordTest extends TestCase { - /** + /** * @var ProviderInterface|ObjectProphecy */ private $providerMock; diff --git a/tests/EventListener/ExceptionEventListenerTest.php b/tests/EventListener/ExceptionEventListenerTest.php index add5d30..0dba8b9 100755 --- a/tests/EventListener/ExceptionEventListenerTest.php +++ b/tests/EventListener/ExceptionEventListenerTest.php @@ -25,7 +25,7 @@ */ final class ExceptionEventListenerTest extends TestCase { - public function testOnKernelExceptionInvalid(): void + public function testOnKernelExceptionInvalid(): void { if (class_exists(ExceptionEvent::class)) { $eventMock = $this->createMock(ExceptionEvent::class); diff --git a/tests/EventListener/RequestEventListenerTest.php b/tests/EventListener/RequestEventListenerTest.php index 23642e1..d1b46cb 100755 --- a/tests/EventListener/RequestEventListenerTest.php +++ b/tests/EventListener/RequestEventListenerTest.php @@ -35,7 +35,7 @@ */ final class RequestEventListenerTest extends TestCase { - /** + /** * @var RequestEventListener */ private $listener; diff --git a/tests/Manager/Bridge/DoctrineManagerTest.php b/tests/Manager/Bridge/DoctrineManagerTest.php index 1ab0bf2..10c5863 100755 --- a/tests/Manager/Bridge/DoctrineManagerTest.php +++ b/tests/Manager/Bridge/DoctrineManagerTest.php @@ -24,7 +24,7 @@ */ final class DoctrineManagerTest extends TestCase { - /** + /** * @var DoctrineManager */ private $doctrineManager; diff --git a/tests/Manager/ForgotPasswordManagerTest.php b/tests/Manager/ForgotPasswordManagerTest.php index 1ec02f8..ce90536 100755 --- a/tests/Manager/ForgotPasswordManagerTest.php +++ b/tests/Manager/ForgotPasswordManagerTest.php @@ -34,7 +34,7 @@ */ final class ForgotPasswordManagerTest extends TestCase { - /** + /** * @var ForgotPasswordManager */ private $manager; diff --git a/tests/Manager/PasswordTokenManagerTest.php b/tests/Manager/PasswordTokenManagerTest.php index b965da9..915f2c9 100755 --- a/tests/Manager/PasswordTokenManagerTest.php +++ b/tests/Manager/PasswordTokenManagerTest.php @@ -26,7 +26,7 @@ */ final class PasswordTokenManagerTest extends TestCase { - /** + /** * @var PasswordTokenManager */ private $manager; diff --git a/tests/Normalizer/JMSNormalizerTest.php b/tests/Normalizer/JMSNormalizerTest.php index f93481e..c67ff60 100644 --- a/tests/Normalizer/JMSNormalizerTest.php +++ b/tests/Normalizer/JMSNormalizerTest.php @@ -23,7 +23,7 @@ */ final class JMSNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize(): void { $normalizerMock = $this->createMock(ArrayTransformerInterface::class); $passwordTokenMock = $this->createMock(AbstractPasswordToken::class); diff --git a/tests/Normalizer/SymfonyNormalizerTest.php b/tests/Normalizer/SymfonyNormalizerTest.php index 953f2aa..3cba135 100644 --- a/tests/Normalizer/SymfonyNormalizerTest.php +++ b/tests/Normalizer/SymfonyNormalizerTest.php @@ -23,7 +23,7 @@ */ final class SymfonyNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize(): void { $normalizerMock = $this->createMock(NormalizerInterface::class); $passwordTokenMock = $this->createMock(AbstractPasswordToken::class);