mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 07:26:12 +00:00
Fix test to manage private methods on ExportDataNormalizerTrait
This commit is contained in:
parent
f1ff507d0a
commit
fef2fe915a
@ -30,6 +30,26 @@ class ExportDataNormalizerTraitTest extends TestCase
|
||||
{
|
||||
return new class () {
|
||||
use ExportDataNormalizerTrait;
|
||||
|
||||
public function normalizeEntity(object|iterable $entity): array|int|string
|
||||
{
|
||||
return $this->normalizeDoctrineEntity($entity);
|
||||
}
|
||||
|
||||
public function denormalizeEntity(mixed $entity, ObjectRepository $repository)
|
||||
{
|
||||
return $this->denormalizeDoctrineEntity($entity, $repository);
|
||||
}
|
||||
|
||||
public function normalizeD(\DateTimeImmutable|\DateTime $date): string
|
||||
{
|
||||
return $this->normalizeDate($date);
|
||||
}
|
||||
|
||||
public function denormalizeD(string $date): \DateTimeImmutable|\DateTime
|
||||
{
|
||||
return $this->denormalizeDate($date);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -45,8 +65,8 @@ class ExportDataNormalizerTraitTest extends TestCase
|
||||
$repository = $this->prophesize(ObjectRepository::class);
|
||||
$repository->find(1)->willReturn($entity);
|
||||
|
||||
$normalized = $this->buildTrait()->normalizeDoctrineEntity($entity);
|
||||
$actual = $this->buildTrait()->denormalizeDoctrineEntity($normalized, $repository->reveal());
|
||||
$normalized = $this->buildTrait()->normalizeEntity($entity);
|
||||
$actual = $this->buildTrait()->denormalizeEntity($normalized, $repository->reveal());
|
||||
|
||||
self::assertSame($entity, $actual);
|
||||
}
|
||||
@ -72,8 +92,8 @@ class ExportDataNormalizerTraitTest extends TestCase
|
||||
Argument::that(static fn ($arg): bool => in_array(1, $arg['id'] ?? []) && in_array(2, $arg['id'] ?? []))
|
||||
)->willReturn([$entityA, $entityB]);
|
||||
|
||||
$normalized = $this->buildTrait()->normalizeDoctrineEntity([$entityA, $entityB]);
|
||||
$actual = $this->buildTrait()->denormalizeDoctrineEntity($normalized, $repository->reveal());
|
||||
$normalized = $this->buildTrait()->normalizeEntity([$entityA, $entityB]);
|
||||
$actual = $this->buildTrait()->denormalizeEntity($normalized, $repository->reveal());
|
||||
|
||||
self::assertContains(1, array_map(static fn (object $item) => $item->getId(), $actual));
|
||||
self::assertContains(2, array_map(static fn (object $item) => $item->getId(), $actual));
|
||||
@ -85,8 +105,8 @@ class ExportDataNormalizerTraitTest extends TestCase
|
||||
*/
|
||||
public function testNormalizationDate(\DateTimeImmutable|\DateTime $date): void
|
||||
{
|
||||
$normalized = $this->buildTrait()->normalizeDate($date);
|
||||
$actual = $this->buildTrait()->denormalizeDate($normalized);
|
||||
$normalized = $this->buildTrait()->normalizeD($date);
|
||||
$actual = $this->buildTrait()->denormalizeD($normalized);
|
||||
|
||||
self::assertEquals($date, $actual);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user