<?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 CallerHistoryTest extends TestCase
{
    public function testConstructorWithPerson(): void
    {
        $ticket = new Ticket();

        $callerHistory = new CallerHistory($person = new Person(), $ticket);

        self::assertSame($ticket, $callerHistory->getTicket());
        self::assertNull($callerHistory->getEndDate());
        self::assertSame($person, $callerHistory->getPerson());
        self::assertNull($callerHistory->getThirdParty());
        self::assertSame($person, $callerHistory->getCaller());
    }

    public function testConstructorWithThirdParty(): void
    {
        $ticket = new Ticket();

        $callerHistory = new CallerHistory($thirdParty = new ThirdParty(), $ticket);

        self::assertSame($ticket, $callerHistory->getTicket());
        self::assertNull($callerHistory->getEndDate());
        self::assertNull($callerHistory->getPerson());
        self::assertSame($thirdParty, $callerHistory->getThirdParty());
        self::assertSame($thirdParty, $callerHistory->getCaller());
    }

    public function testSetEndDate(): void
    {
        $ticket = $this->createMock(Ticket::class);
        $callerHistory = new CallerHistory(new ThirdParty(), $ticket);

        $endDate = new \DateTimeImmutable('2023-01-01');
        $callerHistory->setEndDate($endDate);

        self::assertSame($endDate, $callerHistory->getEndDate());
    }
}
