<commit_before><?php declare(strict_types=1);

namespace CultuurNet\UDB3\Event\ValueObjects;

use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use PHPUnit\Framework\TestCase;

class StatusTest extends TestCase
{
    /**
     * @test
     */
    public function itCanSerialize(): void
    {
        $eventStatus = new Status(
            StatusType::unavailable(),
            [
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                new StatusReason(new Language('fr'), 'Le concert de 10/11 a été annulé'),
            ]
        );

        $this->assertEquals(
            [
                'eventStatus' => 'EventCancelled',
                'eventStatusReason' => [
                    'nl' => 'Het concert van 10/11 is afgelast',
                    'fr' => 'Le concert de 10/11 a été annulé',
                ],
            ],
            $eventStatus->serialize()
        );
    }

    /**
     * @test
     */
    public function itCanDeserialize(): void
    {
        $actualEventStatus = Status::deserialize(
            [
                'eventStatus' => 'EventCancelled',
                'eventStatusReason' => [
                    'nl' => 'Het concert van 10/11 is afgelast',
                    'fr' => 'Le concert de 10/11 a été annulé',
                ],
            ]
        );

        $this->assertEquals(
            new Status(
                StatusType::unavailable(),
                [
                    new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                    new StatusReason(new Language('fr'), 'Le concert de 10/11 a été annulé'),
                ]
            ),
            $actualEventStatus
        );
    }

    /**
     * @test
     */
    public function itCanOnlyHoldOneTranslationPerLanguage(): void
    {
        $this->expectException(\InvalidArgumentException::class);
        new Status(
            StatusType::unavailable(),
            [
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is stiekem toch niet afgelast'),
            ]
        );<commit_msg>Rename variables for clarity<commit_after><?php declare(strict_types=1);

namespace CultuurNet\UDB3\Event\ValueObjects;

use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use PHPUnit\Framework\TestCase;

class StatusTest extends TestCase
{
    /**
     * @test
     */
    public function itCanSerialize(): void
    {
        $status = new Status(
            StatusType::unavailable(),
            [
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                new StatusReason(new Language('fr'), 'Le concert de 10/11 a été annulé'),
            ]
        );

        $this->assertEquals(
            [
                'eventStatus' => 'EventCancelled',
                'eventStatusReason' => [
                    'nl' => 'Het concert van 10/11 is afgelast',
                    'fr' => 'Le concert de 10/11 a été annulé',
                ],
            ],
            $status->serialize()
        );
    }

    /**
     * @test
     */
    public function itCanDeserialize(): void
    {
        $actualStatus = Status::deserialize(
            [
                'eventStatus' => 'EventCancelled',
                'eventStatusReason' => [
                    'nl' => 'Het concert van 10/11 is afgelast',
                    'fr' => 'Le concert de 10/11 a été annulé',
                ],
            ]
        );

        $this->assertEquals(
            new Status(
                StatusType::unavailable(),
                [
                    new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                    new StatusReason(new Language('fr'), 'Le concert de 10/11 a été annulé'),
                ]
            ),
            $actualStatus
        );
    }

    /**
     * @test
     */
    public function itCanOnlyHoldOneTranslationPerLanguage(): void
    {
        $this->expectException(\InvalidArgumentException::class);
        new Status(
            StatusType::unavailable(),
            [
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is afgelast'),
                new StatusReason(new Language('nl'), 'Het concert van 10/11 is stiekem toch niet afgelast'),
            ]
        );
{'fraction_non_alphanumeric': 0.11489074115791845, 'fraction_numerical': 0.019373732822707816, 'mean_word_length': 1.5198637911464246, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3297798', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1154, 'n_words': 281}