mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-03 16:01:23 +00:00
Add getSupportedTypes and update method signatures in test normalizers
This commit is contained in:
@@ -61,6 +61,11 @@ final class UserNormalizerTest extends TestCase
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
$this->assertEquals($expected, $normalizer->normalize($user, $format, $context));
|
||||
|
||||
@@ -145,12 +145,12 @@ final class PersonJsonNormalizerTest extends TestCase
|
||||
|
||||
// Inner normalizer that echoes values or simple conversions
|
||||
$inner = new class () implements NormalizerInterface {
|
||||
public function supportsNormalization($data, $format = null): bool
|
||||
public function supportsNormalization($data, $format = null, array $context = []): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function normalize($object, $format = null, array $context = [])
|
||||
public function normalize($object, $format = null, array $context = []): float|int|bool|\ArrayObject|array|string|null
|
||||
{
|
||||
// For scalars and arrays, return as-is; for objects, return string or id when possible
|
||||
if (\is_scalar($object) || null === $object) {
|
||||
@@ -169,6 +169,11 @@ final class PersonJsonNormalizerTest extends TestCase
|
||||
// default stub
|
||||
return (string) (method_exists($object, 'getId') ? $object->getId() : 'normalized');
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
$normalizer->setNormalizer($inner);
|
||||
|
||||
@@ -145,10 +145,15 @@ final class MotiveNormalizerTest extends TestCase
|
||||
return ['normalized'];
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null): bool
|
||||
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user