Files
chill-bundles/src/Bundle/ChillTicketBundle/tests/Entity/TicketCallerTest.php

83 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\TicketBundle\Tests\Entity;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\TicketBundle\Entity\CallerHistory;
use Chill\TicketBundle\Entity\Ticket;
use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
class TicketCallerTest extends TestCase
{
public function testGetCaller(): void
{
$ticket = new Ticket();
// Initially, there should be no caller
self::assertNull($ticket->getCaller());
// Create a person
$person = new Person();
// Create a caller history with the person
$callerHistory = new CallerHistory($person, $ticket);
// The ticket should now return the person as the caller
self::assertSame($person, $ticket->getCaller());
// Create a third party
$thirdParty = new ThirdParty();
// Create a new caller history with the third party
$callerHistory2 = new CallerHistory($thirdParty, $ticket);
// End the first caller history
$callerHistory->setEndDate(new \DateTimeImmutable());
// The ticket should now return the third party as the caller
self::assertSame($thirdParty, $ticket->getCaller());
// End the second caller history
$callerHistory2->setEndDate(new \DateTimeImmutable());
// The ticket should now return null as there is no active caller
self::assertNull($ticket->getCaller());
}
public function testGetCallerHistories(): void
{
$ticket = new Ticket();
// Initially, there should be no caller histories
self::assertCount(0, $ticket->getCallerHistories());
// Create a caller history
$callerHistory = new CallerHistory(new Person(), $ticket);
// The ticket should now have one caller history
self::assertCount(1, $ticket->getCallerHistories());
self::assertSame($callerHistory, $ticket->getCallerHistories()->first());
// Create another caller history
$callerHistory2 = new CallerHistory(new ThirdParty(), $ticket);
// The ticket should now have two caller histories
self::assertCount(2, $ticket->getCallerHistories());
}
}