mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Docgen/action add missing goals
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?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 Chill\ThirdPartyBundle\Test\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ThirdPartyDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testAvoidRecursionWithNullParent()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']))
|
||||
->setParent(new ThirdParty());
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', ['groups' => ['docgen:read'], 'docgen:expects' => ThirdParty::class]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
<?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 Chill\ThirdPartyBundle\Test\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ThirdpartyDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user