This commit is contained in:
2025-06-20 17:31:13 +02:00
parent 9158e33854
commit a38116cca4
65 changed files with 2298 additions and 2298 deletions

View File

@@ -38,6 +38,34 @@ final class UserNormalizerTest extends TestCase
{
use ProphecyTrait;
/**
* @dataProvider dataProviderUserNormalizer
*
* @throws ExceptionInterface
*/
public function testNormalize(?User $user, mixed $format, mixed $context, mixed $expected)
{
$userRender = $this->prophesize(UserRender::class);
$userRender->renderString(Argument::type(User::class), Argument::type('array'))->willReturn($user ? $user->getLabel() : '');
$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 = [])
{
return ['context' => $context['docgen:expects'] ?? null];
}
public function supportsNormalization($data, ?string $format = null)
{
return true;
}
});
$this->assertEquals($expected, $normalizer->normalize($user, $format, $context));
}
/**
* @throws NumberParseException
*/
@@ -112,32 +140,4 @@ final class UserNormalizerTest extends TestCase
'main_center' => ['context' => Center::class],
]];
}
/**
* @dataProvider dataProviderUserNormalizer
*
* @throws ExceptionInterface
*/
public function testNormalize(?User $user, mixed $format, mixed $context, mixed $expected)
{
$userRender = $this->prophesize(UserRender::class);
$userRender->renderString(Argument::type(User::class), Argument::type('array'))->willReturn($user ? $user->getLabel() : '');
$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 = [])
{
return ['context' => $context['docgen:expects'] ?? null];
}
public function supportsNormalization($data, ?string $format = null)
{
return true;
}
});
$this->assertEquals($expected, $normalizer->normalize($user, $format, $context));
}
}