mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
Serialize ticket's Comment
This commit is contained in:
@@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\TicketBundle\Tests\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\TicketBundle\Entity\Comment;
|
||||
use Chill\TicketBundle\Entity\Motive;
|
||||
use Chill\TicketBundle\Entity\MotiveHistory;
|
||||
use Chill\TicketBundle\Entity\PersonHistory;
|
||||
@@ -93,11 +95,20 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
// datetime
|
||||
$normalizer->normalize(Argument::type(\DateTimeImmutable::class), 'json', Argument::type('array'))
|
||||
->will(function ($args) { return $args[0]->getTimestamp(); });
|
||||
// user
|
||||
$normalizer->normalize(Argument::type(User::class), 'json', Argument::type('array'))
|
||||
->willReturn(['user']);
|
||||
// motive
|
||||
$normalizer->normalize(Argument::type(Motive::class), 'json', Argument::type('array'))->willReturn(['type' => 'motive', 'id' => 0]);
|
||||
// person history
|
||||
$normalizer->normalize(Argument::type(PersonHistory::class), 'json', Argument::type('array'))
|
||||
->willReturn(['personHistory']);
|
||||
// motive history
|
||||
$normalizer->normalize(Argument::type(MotiveHistory::class), 'json', Argument::type('array'))
|
||||
->willReturn(['motiveHistory']);
|
||||
$normalizer->normalize(Argument::type(Comment::class), 'json', Argument::type('array'))
|
||||
->willReturn(['comment']);
|
||||
// null values
|
||||
$normalizer->normalize(null, 'json', Argument::type('array'))->willReturn(null);
|
||||
|
||||
$ticketNormalizer = new TicketNormalizer();
|
||||
@@ -109,6 +120,7 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
public static function provideTickets(): iterable
|
||||
{
|
||||
yield [
|
||||
// this a nearly empty ticket
|
||||
new Ticket(),
|
||||
[
|
||||
'type' => 'ticket_ticket',
|
||||
@@ -122,10 +134,14 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
],
|
||||
];
|
||||
|
||||
// ticket with more features
|
||||
$ticket = new Ticket();
|
||||
$ticket->setExternalRef('2134');
|
||||
$personHistory = new PersonHistory(new Person(), $ticket, new \DateTimeImmutable('2024-04-01T12:00:00'));
|
||||
$ticketHistory = new MotiveHistory(new Motive(), $ticket, new \DateTimeImmutable('2024-04-01T12:02:00'));
|
||||
$comment = new Comment('blabla test', $ticket);
|
||||
$comment->setCreatedAt(new \DateTimeImmutable('2024-04-01T12:04:00'));
|
||||
$comment->setCreatedBy(new User());
|
||||
|
||||
yield [
|
||||
$ticket,
|
||||
@@ -137,7 +153,7 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
'currentAddressees' => [],
|
||||
'currentInputs' => [],
|
||||
'currentMotive' => ['type' => 'motive', 'id' => 0],
|
||||
'history' => [['event_type' => 'add_person'], ['event_type' => 'set_motive']],
|
||||
'history' => [['event_type' => 'add_person'], ['event_type' => 'set_motive'], ['event_type' => 'add_comment']],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user