From a533ab77edef93d146514e16c2bbadbd63910d41 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 12 Feb 2024 18:44:32 +0100 Subject: [PATCH] fix userNormalizerTest by adding clock in the construct of UserNormalizer --- .../Tests/Serializer/Normalizer/UserNormalizerTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php index 15334298e..0219e5a5e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php @@ -25,6 +25,7 @@ use libphonenumber\PhoneNumberUtil; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Clock\MockClock; use Symfony\Component\Serializer\Exception\ExceptionInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -122,7 +123,9 @@ final class UserNormalizerTest extends TestCase $userRender = $this->prophesize(UserRender::class); $userRender->renderString(Argument::type(User::class), Argument::type('array'))->willReturn($user ? $user->getLabel() : ''); - $normalizer = new UserNormalizer($userRender->reveal()); + $clock = new MockClock(new \DateTimeImmutable('now')); + + $normalizer = new UserNormalizer($userRender->reveal(), $clock); $normalizer->setNormalizer(new class () implements NormalizerInterface { public function normalize($object, ?string $format = null, array $context = []) {