mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add docgen:normalization for relation
This commit is contained in:
@@ -60,38 +60,6 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
private function buildPersonNormalizer(
|
||||
?PersonRender $personRender = null,
|
||||
?RelationshipRepository $relationshipRepository = null,
|
||||
?TranslatorInterface $translator = null,
|
||||
?TranslatableStringHelper $translatableStringHelper = null
|
||||
): PersonDocGenNormalizer {
|
||||
$normalizer = new PersonDocGenNormalizer(
|
||||
$personRender ?? self::$container->get(PersonRender::class),
|
||||
$relationshipRepository ?? self::$container->get(RelationshipRepository::class),
|
||||
$translator ??self::$container->get(TranslatorInterface::class),
|
||||
$translatableStringHelper ?? self::$container->get(TranslatableStringHelperInterface::class)
|
||||
);
|
||||
$normalizerManager = $this->prophesize(NormalizerInterface::class);
|
||||
$normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true);
|
||||
$normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any())
|
||||
->will(function($args) use ($normalizer) {
|
||||
return $normalizer->normalize($args[0], $args[1], $args[2]);
|
||||
});
|
||||
$normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will(
|
||||
function ($args) {
|
||||
if (is_iterable($args[0])) {
|
||||
$r = [];
|
||||
foreach ($args[0] as $i) { $r[] = ['fake' => true, 'hash' => spl_object_hash($i)];}
|
||||
return $r;
|
||||
}
|
||||
return ['fake' => true, 'hash' => null !== $args[0] ? spl_object_hash($args[0]) : null];
|
||||
});
|
||||
$normalizer->setNormalizer($normalizerManager->reveal());
|
||||
|
||||
return $normalizer;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
Reference in New Issue
Block a user