@@ -27,6 +27,12 @@ protected function setUp()
27
27
{
28
28
parent ::setUp ();
29
29
30
+ // Normalize intl. configuration settings.
31
+ if (\extension_loaded ('intl ' )) {
32
+ $ this ->iniSet ('intl.use_exceptions ' , 0 );
33
+ $ this ->iniSet ('intl.error_level ' , 0 );
34
+ }
35
+
30
36
// Since we test against "de_AT", we need the full implementation
31
37
IntlTestHelper::requireFullIntl ($ this , '57.1 ' );
32
38
@@ -334,4 +340,44 @@ public function testReverseTransformFiveDigitYearsWithTimestamp()
334
340
$ transformer = new DateTimeToLocalizedStringTransformer ('UTC ' , 'UTC ' , null , null , \IntlDateFormatter::GREGORIAN , 'yyyy-MM-dd HH:mm:ss ' );
335
341
$ transformer ->reverseTransform ('20107-03-21 12:34:56 ' );
336
342
}
343
+
344
+ public function testReverseTransformWrapsIntlErrorsWithErrorLevel ()
345
+ {
346
+ if (!\extension_loaded ('intl ' )) {
347
+ $ this ->markTestSkipped ('intl extension is not loaded ' );
348
+ }
349
+
350
+ $ this ->iniSet ('intl.error_level ' , E_WARNING );
351
+
352
+ $ this ->expectException ('Symfony\Component\Form\Exception\TransformationFailedException ' );
353
+ $ transformer = new DateTimeToLocalizedStringTransformer ();
354
+ $ transformer ->reverseTransform ('12345 ' );
355
+ }
356
+
357
+ public function testReverseTransformWrapsIntlErrorsWithExceptions ()
358
+ {
359
+ if (!\extension_loaded ('intl ' )) {
360
+ $ this ->markTestSkipped ('intl extension is not loaded ' );
361
+ }
362
+
363
+ $ this ->iniSet ('intl.use_exceptions ' , 1 );
364
+
365
+ $ this ->expectException ('Symfony\Component\Form\Exception\TransformationFailedException ' );
366
+ $ transformer = new DateTimeToLocalizedStringTransformer ();
367
+ $ transformer ->reverseTransform ('12345 ' );
368
+ }
369
+
370
+ public function testReverseTransformWrapsIntlErrorsWithExceptionsAndErrorLevel ()
371
+ {
372
+ if (!\extension_loaded ('intl ' )) {
373
+ $ this ->markTestSkipped ('intl extension is not loaded ' );
374
+ }
375
+
376
+ $ this ->iniSet ('intl.use_exceptions ' , 1 );
377
+ $ this ->iniSet ('intl.error_level ' , E_WARNING );
378
+
379
+ $ this ->expectException ('Symfony\Component\Form\Exception\TransformationFailedException ' );
380
+ $ transformer = new DateTimeToLocalizedStringTransformer ();
381
+ $ transformer ->reverseTransform ('12345 ' );
382
+ }
337
383
}
0 commit comments