<?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\CoreBundle\Tests\Entity;

use Ferienpass\CoreBundle\Entity\Offer\OfferInterface;
use Ferienpass\CoreBundle\Entity\WorkflowSurvey;
use PHPUnit\Framework\TestCase;

final class WorkflowSurveyTest extends TestCase
{
    public function testGetOfferReturnsOffer(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'satisfaction');

        self::assertSame($offer, $survey->getOffer());
    }

    public function testGetSurveyReturnsSurvey(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'satisfaction');

        self::assertSame('satisfaction', $survey->getSurvey());
    }

    public function testGetIdIsNullByDefault(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'test');

        self::assertNull($survey->getId());
    }

    public function testGetDataIsNullByDefault(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'test');

        self::assertNull($survey->getData());
    }

    public function testSetDataUpdatesData(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'test');
        $survey->setData(['rating' => 5, 'comment' => 'Great!']);

        self::assertSame(['rating' => 5, 'comment' => 'Great!'], $survey->getData());
    }

    public function testSetDataAcceptsNull(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $survey = new WorkflowSurvey($offer, 'test');
        $survey->setData(['some' => 'data']);
        $survey->setData(null);

        self::assertNull($survey->getData());
    }
}
