add basic context for AccompanyingPeriodWorkEvalution WIP

This commit is contained in:
2021-12-03 13:50:35 +01:00
parent e053529afb
commit 23eff9f6d4
7 changed files with 253 additions and 74 deletions

View File

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