fixes on tests

This commit is contained in:
2021-12-08 10:56:39 +00:00
parent 56dd825f39
commit fa5001265f
26 changed files with 146 additions and 136 deletions

View File

@@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Serializer\Normalizer;
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
use ReflectionClass;
use RuntimeException;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
@@ -49,7 +50,11 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
public function normalize($object, ?string $format = null, array $context = [])
{
$classMetadataKey = $object ?? $context['docgen:expects'];
$classMetadataKey = $object ?? $context['docgen:expects'] ?? null;
if (null === $classMetadataKey) {
throw new RuntimeException('Could not determine the metadata for this object. Either provide a non-null object, or a "docgen:expects" key in the context');
}
if (!$this->classMetadataFactory->hasMetadataFor($classMetadataKey)) {
throw new LogicException(sprintf('This object does not have metadata: %s. Add groups on this entity to allow to serialize with the format %s and groups %s', is_object($object) ? get_class($object) : $context['docgen:expects'], $format, implode(', ', $context['groups'])));