<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CmsBundle\Tests\Application\ExclusionReasons;

use Ferienpass\CmsBundle\Application\ExclusionReasonEvent;
use Ferienpass\CmsBundle\Application\ExclusionReasons\DayLimitReachedListener;
use Ferienpass\CoreBundle\ApplicationSystem\ApplicationSystemInterface;
use Ferienpass\CoreBundle\ApplicationSystem\FirstComeApplicationSystem;
use Ferienpass\CoreBundle\Entity\Offer\OfferInterface;
use Ferienpass\CoreBundle\Entity\Participant\ParticipantInterface;
use PHPUnit\Framework\TestCase;

final class DayLimitReachedListenerTest extends TestCase
{
    public function testDoesNothingWhenNotFirstComeSystem(): void
    {
        $appSystem = $this->createMock(ApplicationSystemInterface::class);

        $event = new ExclusionReasonEvent(
            $this->createMock(OfferInterface::class),
            $this->createMock(ParticipantInterface::class),
            $appSystem
        );

        $listener = new DayLimitReachedListener();
        $listener($event);

        $this->addToAssertionCount(1);
    }

    public function testDoesNothingWhenNoTask(): void
    {
        $appSystem = $this->createMock(FirstComeApplicationSystem::class);
        $appSystem->method('getTask')->willReturn(null);

        $event = new ExclusionReasonEvent(
            $this->createMock(OfferInterface::class),
            $this->createMock(ParticipantInterface::class),
            $appSystem
        );

        $listener = new DayLimitReachedListener();
        $listener($event);

        $this->addToAssertionCount(1);
    }

    public function testDoesNothingWhenNoMaxApplicationsDay(): void
    {
        $task = $this->createMock(\Ferienpass\CoreBundle\Entity\EditionTask::class);
        $task->method('getMaxApplicationsDay')->willReturn(null);

        $appSystem = $this->createMock(FirstComeApplicationSystem::class);
        $appSystem->method('getTask')->willReturn($task);

        $event = new ExclusionReasonEvent(
            $this->createMock(OfferInterface::class),
            $this->createMock(ParticipantInterface::class),
            $appSystem
        );

        $listener = new DayLimitReachedListener();
        $listener($event);

        $this->addToAssertionCount(1);
    }
}
