AccompanyingPeriodResource: fix deserialization + code style

This commit is contained in:
2022-01-10 23:08:23 +01:00
parent 8e012982f5
commit 2c4d06371c
8 changed files with 143 additions and 22 deletions

View File

@@ -0,0 +1,51 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Serializer\Normalizer;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
/**
* @internal
* @coversNothing
*/
final class ResourceJsonNormalizerTest extends KernelTestCase
{
private DenormalizerInterface $denormalizer;
protected function setUp(): void
{
self::bootKernel();
$this->denormalizer = self::$container->get(DenormalizerInterface::class);
}
public function testDenormalize()
{
$resource = new Resource();
$context = [
AbstractNormalizer::GROUPS => ['write'],
AbstractNormalizer::OBJECT_TO_POPULATE => $resource,
];
$json = [
'comment' => 'bloup',
'type' => 'accompanying_period_resource',
];
$resource = $this->denormalizer->denormalize($json, Resource::class, 'json', $context);
$this->assertEquals('bloup', $resource->getComment());
}
}