diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 22a5d41b5f88b..b52794aed840f 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -119,6 +119,13 @@ public function reverseTransform(mixed $value): ?\DateTime } if (0 != intl_get_error_code()) { + var_dump($value); + var_dump($this->dateFormat); + var_dump($this->timeFormat); + var_dump($this->calendar); + var_dump($this->pattern); + var_dump(\Locale::getDefault()); + throw new TransformationFailedException(intl_get_error_message(), intl_get_error_code()); } elseif ($timestamp > 253402214400) { // This timestamp represents UTC midnight of 9999-12-31 to prevent 5+ digit years diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 29cacc24223cc..52810d3071f18 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormInterface; +use Symfony\Component\Intl\Intl; use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; @@ -92,7 +93,7 @@ public function testSubmitFromSingleTextDateTimeWithCustomFormat() public function testSubmitFromSingleTextDateTime() { // we test against "de_DE", so we need the full implementation - IntlTestHelper::requireFullIntl($this, false); + IntlTestHelper::requireFullIntl($this, false, true); \Locale::setDefault('de_DE'); @@ -106,6 +107,18 @@ public function testSubmitFromSingleTextDateTime() ]); $form->submit('2.6.2010'); + var_dump(__METHOD__); + var_dump(Intl::getIcuVersion()); + + if (!$form->isValid()) { + /** @var FormError $error */ + foreach ($form->getErrors(true) as $error) { + var_dump($error->getMessage()); + var_dump($error->getCause()->getMessage()); + var_dump($error->getCause()->getInvalidMessage()); + var_dump($error->getCause()->getInvalidMessageParameters()); + } + } $this->assertEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); $this->assertEquals('02.06.2010', $form->getViewData()); diff --git a/src/Symfony/Component/Intl/Util/IntlTestHelper.php b/src/Symfony/Component/Intl/Util/IntlTestHelper.php index d22f2e6953e3f..2d454265cbfdd 100644 --- a/src/Symfony/Component/Intl/Util/IntlTestHelper.php +++ b/src/Symfony/Component/Intl/Util/IntlTestHelper.php @@ -32,9 +32,16 @@ class IntlTestHelper * * @return void */ - public static function requireIntl(TestCase $testCase, string $minimumIcuVersion = null) + public static function requireIntl(TestCase $testCase, string $minimumIcuVersion = null, bool $debug = false) { + if ($debug) { + var_dump(__METHOD__); + var_dump($minimumIcuVersion); + } $minimumIcuVersion ??= Intl::getIcuStubVersion(); + if ($debug) { + var_dump($minimumIcuVersion); + } // We only run tests if the version is *one specific version*. // This condition is satisfied if @@ -66,14 +73,18 @@ public static function requireIntl(TestCase $testCase, string $minimumIcuVersion * * @return void */ - public static function requireFullIntl(TestCase $testCase, string $minimumIcuVersion = null) + public static function requireFullIntl(TestCase $testCase, string $minimumIcuVersion = null, bool $debug = false) { + if ($debug) { + var_dump(__METHOD__); + var_dump($minimumIcuVersion); + } // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $testCase->markTestSkipped('Extension intl is required.'); } - self::requireIntl($testCase, $minimumIcuVersion); + self::requireIntl($testCase, $minimumIcuVersion, $debug); // Consequently, tests will //