mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add basic context for AccompanyingPeriodWorkEvalution WIP
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
<?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\MainBundle\Entity\User;
|
||||
@@ -8,11 +17,16 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
@@ -22,6 +36,31 @@ class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalizationNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [
|
||||
'docgen:expects' => AccompanyingPeriodWork::class,
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
]);
|
||||
|
||||
dump($actual);
|
||||
|
||||
$expected = [
|
||||
'id' => '',
|
||||
];
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
if ('@ignored' === $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals($item, $actual[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
public function testNormlalize()
|
||||
{
|
||||
$work = new AccompanyingPeriodWork();
|
||||
@@ -29,24 +68,22 @@ class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
->addPerson((new Person())->setFirstName('hello')->setLastName('name'))
|
||||
->addGoal($g = new AccompanyingPeriodWorkGoal())
|
||||
->addResult($r = new Result())
|
||||
->setCreatedAt(new \DateTimeImmutable())
|
||||
->setUpdatedAt(new \DateTimeImmutable())
|
||||
->setCreatedAt(new DateTimeImmutable())
|
||||
->setUpdatedAt(new DateTimeImmutable())
|
||||
->setCreatedBy($user = new User())
|
||||
->setUpdatedBy($user)
|
||||
;
|
||||
->setUpdatedBy($user);
|
||||
$g->addResult($r)->setGoal($goal = new Goal());
|
||||
$goal->addResult($r);
|
||||
|
||||
$actual = $this->normalizer->normalize($work, 'docgen', [
|
||||
'docgen:expects' => AccompanyingPeriodWork::class,
|
||||
AbstractNormalizer::GROUPS => ['docgen:read']
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
]);
|
||||
|
||||
var_dump($actual);
|
||||
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
|
||||
];
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
@@ -60,33 +97,4 @@ class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($item, $actual[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
public function testNormalizationNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [
|
||||
'docgen:expects' => AccompanyingPeriodWork::class,
|
||||
AbstractNormalizer::GROUPS => ['docgen:read']
|
||||
]);
|
||||
|
||||
dump($actual);
|
||||
|
||||
$expected = [
|
||||
'id' => ""
|
||||
];
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
if ('@ignored' === $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals($item, $actual[$key]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user