From 4788a04cd0e8f42814632924171bbe9c8e9cebb4 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 16 Jan 2024 15:11:36 +0100 Subject: [PATCH] Add a test covering the usage of translation files in the ICU format --- .../translations/test_icu+intl-icu.en.yml | 2 ++ .../translations/test_icu+intl-icu.fr.yml | 2 ++ tests/FunctionalTest.php | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/FixtureApp/Resources/translations/test_icu+intl-icu.en.yml create mode 100644 tests/FixtureApp/Resources/translations/test_icu+intl-icu.fr.yml diff --git a/tests/FixtureApp/Resources/translations/test_icu+intl-icu.en.yml b/tests/FixtureApp/Resources/translations/test_icu+intl-icu.en.yml new file mode 100644 index 0000000..9f8a633 --- /dev/null +++ b/tests/FixtureApp/Resources/translations/test_icu+intl-icu.en.yml @@ -0,0 +1,2 @@ +first: This is the first message. +second: This is the second message. diff --git a/tests/FixtureApp/Resources/translations/test_icu+intl-icu.fr.yml b/tests/FixtureApp/Resources/translations/test_icu+intl-icu.fr.yml new file mode 100644 index 0000000..b03232c --- /dev/null +++ b/tests/FixtureApp/Resources/translations/test_icu+intl-icu.fr.yml @@ -0,0 +1,2 @@ +first: Ceci est le premier message. +second: Ceci est le second message. diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 4d1b0dc..065667b 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -40,6 +40,25 @@ public function testCompareCommand(string $locale, bool $valid) $this->assertSame($expectedExitCode, $application->run($input, $output)); } + /** + * @dataProvider provideComparisonCases + */ + public function testCompareCommandWithIcuTranslations(string $locale, bool $valid) + { + self::bootKernel(); + + $application = new Application(self::$kernel); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $input = new ArrayInput(array('command' => 'incenteev:translation:compare', 'locale' => $locale, '-d' => array('test_icu'))); + $output = new NullOutput(); + + $expectedExitCode = $valid ? 0 : 1; + + $this->assertSame($expectedExitCode, $application->run($input, $output)); + } + public static function provideComparisonCases(): iterable { return array(