Add getSupportedTypes and update method signatures in test normalizers

This commit is contained in:
2026-01-02 15:10:48 +01:00
parent bbbf9aa3ee
commit b0cb08a07d
3 changed files with 18 additions and 3 deletions

View File

@@ -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));

View File

@@ -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);

View File

@@ -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 [];
}
};
}
}