mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-07 13:59:43 +00:00
fixes on tests
This commit is contained in:
@@ -13,7 +13,8 @@ namespace Chill\DocGeneratorBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext;
|
||||
use DateTime;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
@@ -35,8 +36,9 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
'iv' => '[86,231,83,148,117,107,149,173,130,19,105,194,224,145,8,48]',
|
||||
'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
],
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => [AccompanyingPeriodWorkEvaluation::class],
|
||||
'context' => AccompanyingPeriodContext::class,
|
||||
'entity' => AccompanyingPeriod::class,
|
||||
'options' => ['mainPerson' => false, 'person1' => false, 'person2' => false],
|
||||
], [
|
||||
'name' => ['fr' => 'AIDE ALIMENTAIRE'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
@@ -46,8 +48,9 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
'iv' => '[86,231,83,148,117,107,149,173,130,19,105,194,224,145,8,48]',
|
||||
'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
],
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction', AccompanyingPeriodWorkEvaluation::class],
|
||||
'context' => AccompanyingPeriodContext::class,
|
||||
'entity' => AccompanyingPeriod::class,
|
||||
'options' => ['mainPerson' => false, 'person1' => false, 'person2' => false],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -68,11 +71,11 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
->setDescription($template['desc'])
|
||||
->setFile($newStoredObj)
|
||||
->setContext($template['context'])
|
||||
->setEntities($template['entities']);
|
||||
->setEntity($template['entity'])
|
||||
->setOptions($template['options']);
|
||||
|
||||
$manager->persist($newTemplate);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@@ -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'])));
|
||||
|
@@ -40,7 +40,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$user->setMainCenter($center = new Center());
|
||||
$center->setName('test');
|
||||
|
||||
$normalized = $this->normalizer->normalize($user, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read']]);
|
||||
$normalized = $this->normalizer->normalize($user, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => User::class]);
|
||||
$expected = [
|
||||
'label' => 'User Test',
|
||||
'email' => '',
|
||||
@@ -75,7 +75,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$user = new User();
|
||||
$user->setUsername('User Test');
|
||||
|
||||
$normalized = $this->normalizer->normalize($user, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read']]);
|
||||
$normalized = $this->normalizer->normalize($user, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => User::class]);
|
||||
$expected = [
|
||||
'label' => 'User Test',
|
||||
'email' => '',
|
||||
|
Reference in New Issue
Block a user