Repository: symfony/symfony
File: src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php (PHP)

Code before:
        parent::setUp();
    }

    public function testCurrenciesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'Euro'), $choices);
        $this->assertContainsEquals(new ChoiceView('USD', 'USD', 'US Dollar'), $choices);
    }

    #[RequiresPhpExtension('intl')]
    public function testChoiceTranslationLocaleOption()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                'choice_translation_locale' => 'uk',
            ])
            ->createView()->vars['choices'];

        // Don't check objects for identity
        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'євро'), $choices);
        $this->assertContainsEquals(new ChoiceView('USD', 'USD', 'долар США'), $choices);
    }

    public function testSubmitNull($expected = null, $norm = null, $view = null)
    {
        parent::testSubmitNull($expected, $norm, '');
    }

    public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expectedData = 'EUR')
    {
        parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
    }

    #[RequiresPhpExtension('intl')]
    public function testAnActiveAndLegalTenderCurrencyIn2006()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                'choice_translation_locale' => 'fr',
                'active' => true,
                'legal_tender' => true,
                'active_or_not_at' => new \DateTimeImmutable('2006-01-01', new \DateTimeZone('Etc/UTC')),
            ])
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'tolar slovène'), $choices);
    }


Review comment (suggestion):
Note: As the `CurrencyType` exclude obsolete currencies by default, I had to exclude this assertion to make the test pass (`SIT` currency is no longer valid).

Code after:

        parent::setUp();
    }

    public function testCurrenciesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'Euro'), $choices);
        $this->assertContainsEquals(new ChoiceView('USD', 'USD', 'US Dollar'), $choices);
    }

    #[RequiresPhpExtension('intl')]
    public function testChoiceTranslationLocaleOption()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                'choice_translation_locale' => 'uk',
            ])
            ->createView()->vars['choices'];

        // Don't check objects for identity
        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'євро'), $choices);
        $this->assertContainsEquals(new ChoiceView('USD', 'USD', 'долар США'), $choices);
    }

    public function testSubmitNull($expected = null, $norm = null, $view = null)
    {
        parent::testSubmitNull($expected, $norm, '');
    }

    public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expectedData = 'EUR')
    {
        parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
    }

    #[RequiresPhpExtension('intl')]
    public function testAnActiveAndLegalTenderCurrencyIn2006()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                'choice_translation_locale' => 'fr',
                'active_at' => new \DateTimeImmutable('2006-01-01', new \DateTimeZone('Etc/UTC')),
                'legal_tender' => true,
            ])
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'tolar slovène'), $choices);
    }