Add functionality to set addressees for a ticket

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.
This commit is contained in:
2024-04-23 17:47:07 +02:00
parent 9f355032a8
commit b434d38091
15 changed files with 677 additions and 3 deletions

View File

@@ -11,7 +11,10 @@ declare(strict_types=1);
namespace Chill\TicketBundle\Tests\Entity;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\PersonBundle\Entity\Person;
use Chill\TicketBundle\Entity\AddresseeHistory;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\MotiveHistory;
use Chill\TicketBundle\Entity\PersonHistory;
@@ -57,5 +60,33 @@ class TicketTest extends KernelTestCase
self::assertCount(1, $ticket->getPersons());
self::assertSame($person, $ticket->getPersons()[0]);
$history->setEndDate(new \DateTimeImmutable('now'));
self::assertCount(0, $ticket->getPersons());
}
public function testGetAddresse(): void
{
$ticket = new Ticket();
$user = new User();
$group = new UserGroup();
self::assertEquals([], $ticket->getCurrentAddressee());
$history = new AddresseeHistory($user, new \DateTimeImmutable('now'), $ticket);
self::assertCount(1, $ticket->getCurrentAddressee());
self::assertSame($user, $ticket->getCurrentAddressee()[0]);
$history2 = new AddresseeHistory($group, new \DateTimeImmutable('now'), $ticket);
self::assertCount(2, $ticket->getCurrentAddressee());
self::assertContains($group, $ticket->getCurrentAddressee());
$history->setEndDate(new \DateTimeImmutable('now'));
self::assertCount(1, $ticket->getCurrentAddressee());
self::assertSame($group, $ticket->getCurrentAddressee()[0]);
}
}