mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,53 +1,25 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\PersonDocGenNormalizer;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateData
|
||||
*/
|
||||
public function testNormalize(?Person $person, $expected, $msg)
|
||||
{
|
||||
$normalized = $this->normalizer->normalize($person, 'docgen', ['docgen:expects' => Person::class]);
|
||||
|
||||
$this->assertEquals($expected, $normalized, $msg);
|
||||
}
|
||||
|
||||
public function generateData()
|
||||
{
|
||||
$person = new Person();
|
||||
$person
|
||||
->setFirstName('Renaud')
|
||||
->setLastName('Mégane')
|
||||
;
|
||||
|
||||
$expected = \array_merge(
|
||||
self::BLANK, ['firstname' => 'Renaud', 'lastname' => 'Mégane',
|
||||
'text' => 'Renaud Mégane']
|
||||
);
|
||||
|
||||
yield [$person, $expected, 'partial normalization for a person'];
|
||||
|
||||
yield [null, self::BLANK, 'normalization for a null person'];
|
||||
}
|
||||
|
||||
|
||||
private const BLANK = [
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
@@ -65,7 +37,46 @@ class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
'nationality' => '',
|
||||
'placeOfBirth' => '',
|
||||
'memo' => '',
|
||||
'numberOfChildren' => ''
|
||||
'numberOfChildren' => '',
|
||||
];
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function generateData()
|
||||
{
|
||||
$person = new Person();
|
||||
$person
|
||||
->setFirstName('Renaud')
|
||||
->setLastName('Mégane');
|
||||
|
||||
$expected = array_merge(
|
||||
self::BLANK,
|
||||
['firstname' => 'Renaud', 'lastname' => 'Mégane',
|
||||
'text' => 'Renaud Mégane', ]
|
||||
);
|
||||
|
||||
yield [$person, $expected, 'partial normalization for a person'];
|
||||
|
||||
yield [null, self::BLANK, 'normalization for a null person'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateData
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param mixed $msg
|
||||
*/
|
||||
public function testNormalize(?Person $person, $expected, $msg)
|
||||
{
|
||||
$normalized = $this->normalizer->normalize($person, 'docgen', ['docgen:expects' => Person::class]);
|
||||
|
||||
$this->assertEquals($expected, $normalized, $msg);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user