mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
Add StateHistory
and StateEnum
entities to track ticket state changes
Integrated the `StateHistory` entity to manage state transitions in tickets and the `StateEnum` for defining state values (`open`, `closed`). Updated `Ticket` to handle associations with state histories and provide state management methods. Added migration for `state_history` table and extended `TicketTest` for state-related tests.
This commit is contained in:
@@ -18,6 +18,8 @@ use Chill\TicketBundle\Entity\AddresseeHistory;
|
||||
use Chill\TicketBundle\Entity\Motive;
|
||||
use Chill\TicketBundle\Entity\MotiveHistory;
|
||||
use Chill\TicketBundle\Entity\PersonHistory;
|
||||
use Chill\TicketBundle\Entity\StateEnum;
|
||||
use Chill\TicketBundle\Entity\StateHistory;
|
||||
use Chill\TicketBundle\Entity\Ticket;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
@@ -108,4 +110,29 @@ class TicketTest extends KernelTestCase
|
||||
// Verify that getExternalRef returns the updated value
|
||||
self::assertSame($newExternalRef, $ticket->getExternalRef());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// Verify that the ticket now has the open state
|
||||
self::assertSame($openState, $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);
|
||||
|
||||
// Verify that the ticket now has the closed state
|
||||
self::assertCount(2, $ticket->getStateHistories());
|
||||
self::assertSame($closedState, $ticket->getState());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user