mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-08 02:11:23 +00:00
This update includes the implementation of methods to add and retrieve addressee history in the Ticket entity, a handler for addressee setting command, denormalizer for transforming request data to SetAddresseesCommand, and corresponding tests. Additionally, it adds a SetAddresseesController for handling addressee related requests and updates the API specifications.
67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* 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 Chill\TicketBundle\Tests\Serializer\Normalizer;
|
|
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\MainBundle\Entity\UserGroup;
|
|
use Chill\TicketBundle\Action\Ticket\SetAddresseesCommand;
|
|
use Chill\TicketBundle\Serializer\Normalizer\SetAddresseesCommandDenormalizer;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Prophecy\Argument;
|
|
use Prophecy\PhpUnit\ProphecyTrait;
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @coversNothing
|
|
*/
|
|
class SetAddresseesCommandDenormalizerTest extends TestCase
|
|
{
|
|
use ProphecyTrait;
|
|
|
|
public function testSupportsDenormalization()
|
|
{
|
|
$denormalizer = new SetAddresseesCommandDenormalizer();
|
|
|
|
self::assertTrue($denormalizer->supportsDenormalization('', SetAddresseesCommand::class, 'json'));
|
|
self::assertFalse($denormalizer->supportsDenormalization('', stdClass::class, 'json'));
|
|
}
|
|
|
|
public function testDenormalize()
|
|
{
|
|
$denormalizer = $this->buildDenormalizer();
|
|
|
|
$actual = $denormalizer->denormalize(['addressees' => [['type' => 'user'], ['type' => 'user_group']]], SetAddresseesCommand::class, 'json');
|
|
|
|
self::assertInstanceOf(SetAddresseesCommand::class, $actual);
|
|
self::assertIsArray($actual->addressees);
|
|
self::assertCount(2, $actual->addressees);
|
|
self::assertInstanceOf(User::class, $actual->addressees[0]);
|
|
self::assertInstanceOf(UserGroup::class, $actual->addressees[1]);
|
|
}
|
|
|
|
private function buildDenormalizer(): SetAddresseesCommandDenormalizer
|
|
{
|
|
$normalizer = $this->prophesize(DenormalizerInterface::class);
|
|
$normalizer->denormalize(Argument::any(), User::class, 'json', Argument::any())
|
|
->willReturn(new User());
|
|
$normalizer->denormalize(Argument::any(), UserGroup::class, 'json', Argument::any())
|
|
->willReturn(new UserGroup());
|
|
|
|
$denormalizer = new SetAddresseesCommandDenormalizer();
|
|
$denormalizer->setDenormalizer($normalizer->reveal());
|
|
|
|
return $denormalizer;
|
|
}
|
|
}
|