getMotive()); $history = new MotiveHistory($motive, $ticket); self::assertSame($motive, $ticket->getMotive()); self::assertCount(1, $ticket->getMotiveHistories()); // replace motive $motive2 = new Motive(); $history->setEndDate(new \DateTimeImmutable()); $history2 = new MotiveHistory($motive2, $ticket); self::assertCount(2, $ticket->getMotiveHistories()); self::assertSame($motive2, $ticket->getMotive()); } public function testGetPerson(): void { $ticket = new Ticket(); $person = new Person(); self::assertEquals([], $ticket->getPersons()); $history = new PersonHistory($person, $ticket, new \DateTimeImmutable('now')); 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]); } public function testGetAndSetExternalRef(): void { $ticket = new Ticket(); $externalRef = 'REF-123'; // Set the external reference $ticket->setExternalRef($externalRef); // Verify that getExternalRef returns the correct value self::assertSame($externalRef, $ticket->getExternalRef()); // Change the external reference $newExternalRef = 'REF-456'; $ticket->setExternalRef($newExternalRef); // Verify that getExternalRef returns the updated value self::assertSame($newExternalRef, $ticket->getExternalRef()); } public function testGetState(): void { $ticket = new Ticket(); // Initially, the ticket has no state self::assertNull($ticket->getState()); // Create a state history entry with the open state $history = new StateHistory(StateEnum::OPEN, $ticket); // Verify that the ticket now has the open state self::assertSame(StateEnum::OPEN, $ticket->getState()); self::assertCount(1, $ticket->getStateHistories()); // Change the state to closed $history->setEndDate(new \DateTimeImmutable()); $history2 = new StateHistory(StateEnum::CLOSED, $ticket); // Verify that the ticket now has the closed state self::assertCount(2, $ticket->getStateHistories()); self::assertSame(StateEnum::CLOSED, $ticket->getState()); } public function testGetEmergencyStatus(): void { $ticket = new Ticket(); // Initially, the ticket has no emergency status self::assertNull($ticket->getEmergencyStatus()); // Create an emergency status history entry with the YES status $history = new EmergencyStatusHistory(EmergencyStatusEnum::YES, $ticket); // Verify that the ticket now has the YES status self::assertSame(EmergencyStatusEnum::YES, $ticket->getEmergencyStatus()); self::assertCount(1, $ticket->getEmergencyStatusHistories()); // Change the emergency status to NO $history->setEndDate(new \DateTimeImmutable()); $history2 = new EmergencyStatusHistory(EmergencyStatusEnum::NO, $ticket); // Verify that the ticket now has the NO status self::assertCount(2, $ticket->getEmergencyStatusHistories()); self::assertSame(EmergencyStatusEnum::NO, $ticket->getEmergencyStatus()); } }