mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-18 08:14:24 +00:00
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?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\ThirdPartyBundle\Entity\ThirdParty;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
|
|
/**
|
|
* @internal
|
|
* @coversNothing
|
|
*/
|
|
final class ThirdPartyJsonDenormalizerTest extends KernelTestCase
|
|
{
|
|
private DenormalizerInterface $normalizer;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
self::bootKernel();
|
|
|
|
$this->normalizer = self::$container->get(DenormalizerInterface::class);
|
|
}
|
|
|
|
public function testDenormalizeContact()
|
|
{
|
|
$str = <<<'JSON'
|
|
{
|
|
"type": "thirdparty",
|
|
"name": "badaboum",
|
|
"email": "badaboum@email.com",
|
|
"telephone": "+32486540660",
|
|
"kind": "contact"
|
|
}
|
|
JSON;
|
|
|
|
$actual = $this->normalizer->denormalize(json_decode($str, true), ThirdParty::class, 'json', [
|
|
'groups' => ['write'],
|
|
]);
|
|
|
|
$this->assertInstanceOf(ThirdParty::class, $actual);
|
|
$this->assertEquals('badaboum', $actual->getName());
|
|
$this->assertEquals('badaboum@email.com', $actual->getEmail());
|
|
$this->assertEquals(ThirdParty::KIND_CONTACT, $actual->getKind());
|
|
}
|
|
}
|