Add addressee history to ticket serialization

This update extends the tickets serialization and normalisation process to include addressee history. With the changes, AddresseeHistory class now also keeps track of who removed an addressee. Additional types, tests and interfaces have been introduced to support this change.
This commit is contained in:
2024-04-23 23:39:01 +02:00
parent ed45f14a45
commit 45828174d1
5 changed files with 89 additions and 9 deletions

View File

@@ -12,7 +12,9 @@ declare(strict_types=1);
namespace Chill\TicketBundle\Tests\Serializer\Normalizer;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\PersonBundle\Entity\Person;
use Chill\TicketBundle\Entity\AddresseeHistory;
use Chill\TicketBundle\Entity\Comment;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\MotiveHistory;
@@ -108,6 +110,8 @@ class TicketNormalizerTest extends KernelTestCase
->willReturn(['motiveHistory']);
$normalizer->normalize(Argument::type(Comment::class), 'json', Argument::type('array'))
->willReturn(['comment']);
$normalizer->normalize(Argument::type(AddresseeHistory::class), 'json', Argument::type('array'))
->willReturn(['addresseeHistory']);
// null values
$normalizer->normalize(null, 'json', Argument::type('array'))->willReturn(null);
@@ -142,6 +146,9 @@ class TicketNormalizerTest extends KernelTestCase
$comment = new Comment('blabla test', $ticket);
$comment->setCreatedAt(new \DateTimeImmutable('2024-04-01T12:04:00'));
$comment->setCreatedBy(new User());
$addresseeHistory = new AddresseeHistory(new User(), new \DateTimeImmutable('2024-04-01T12:05:00'), $ticket);
$addresseeHistory->setEndDate(new \DateTimeImmutable('2024-04-01T12:06:00'));
new AddresseeHistory(new UserGroup(), new \DateTimeImmutable('2024-04-01T12:07:00'), $ticket);
yield [
$ticket,
@@ -150,10 +157,17 @@ class TicketNormalizerTest extends KernelTestCase
'id' => null,
'externalRef' => '2134',
'currentPersons' => ['embedded'],
'currentAddressees' => [],
'currentAddressees' => ['embedded'],
'currentInputs' => [],
'currentMotive' => ['type' => 'motive', 'id' => 0],
'history' => [['event_type' => 'add_person'], ['event_type' => 'set_motive'], ['event_type' => 'add_comment']],
'history' => [
['event_type' => 'add_person'],
['event_type' => 'set_motive'],
['event_type' => 'add_comment'],
['event_type' => 'add_addressee'],
['event_type' => 'remove_addressee'],
['event_type' => 'add_addressee'],
],
],
];
}