Serialization of tickets with history

This commit is contained in:
2024-04-18 11:35:07 +02:00
parent 670b8eb82b
commit 467bea7cde
13 changed files with 353 additions and 12 deletions

View File

@@ -11,8 +11,10 @@ declare(strict_types=1);
namespace Chill\TicketBundle\Tests\Entity;
use Chill\PersonBundle\Entity\Person;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\MotiveHistory;
use Chill\TicketBundle\Entity\PersonHistory;
use Chill\TicketBundle\Entity\Ticket;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -31,7 +33,6 @@ class TicketTest extends KernelTestCase
self::assertNull($ticket->getMotive());
$history = new MotiveHistory($motive, $ticket);
$ticket->addMotiveHistory($history);
self::assertSame($motive, $ticket->getMotive());
self::assertCount(1, $ticket->getMotiveHistories());
@@ -39,9 +40,22 @@ class TicketTest extends KernelTestCase
// replace motive
$motive2 = new Motive();
$history->setEndDate(new \DateTimeImmutable());
$ticket->addMotiveHistory(new MotiveHistory($motive2, $ticket));
$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]);
}
}