Add api endpoint to open and close ticket

This commit is contained in:
2025-06-20 15:42:43 +00:00
parent 95975fae55
commit c72432efae
21 changed files with 685 additions and 84 deletions

View File

@@ -114,25 +114,23 @@ class TicketTest extends KernelTestCase
public function testGetState(): void
{
$ticket = new Ticket();
$openState = new StateEnum(StateEnum::OPEN, ['en' => 'Open', 'fr' => 'Ouvert']);
// Initially, the ticket has no state
self::assertNull($ticket->getState());
// Create a state history entry with the open state
$history = new StateHistory($openState, $ticket);
$history = new StateHistory(StateEnum::OPEN, $ticket);
// Verify that the ticket now has the open state
self::assertSame($openState, $ticket->getState());
self::assertSame(StateEnum::OPEN, $ticket->getState());
self::assertCount(1, $ticket->getStateHistories());
// Change the state to closed
$closedState = new StateEnum(StateEnum::CLOSED, ['en' => 'Closed', 'fr' => 'Fermé']);
$history->setEndDate(new \DateTimeImmutable());
$history2 = new StateHistory($closedState, $ticket);
$history2 = new StateHistory(StateEnum::CLOSED, $ticket);
// Verify that the ticket now has the closed state
self::assertCount(2, $ticket->getStateHistories());
self::assertSame($closedState, $ticket->getState());
self::assertSame(StateEnum::CLOSED, $ticket->getState());
}
}