@@ -141,10 +141,10 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
141
141
*/
142
142
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot ()
143
143
{
144
- // Since we test against "de_AT ", we need the full implementation
144
+ // Since we test against "de_DE ", we need the full implementation
145
145
IntlTestHelper::requireFullIntl ($ this , '4.8.1.1 ' );
146
146
147
- \Locale::setDefault ('de_AT ' );
147
+ \Locale::setDefault ('de_DE ' );
148
148
149
149
$ transformer = new PercentToLocalizedStringTransformer (1 , 'integer ' );
150
150
@@ -236,4 +236,70 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGro
236
236
$ this ->assertEquals (1234.5 , $ transformer ->reverseTransform ('1234,5 ' ));
237
237
$ this ->assertEquals (1234.5 , $ transformer ->reverseTransform ('1234.5 ' ));
238
238
}
239
+
240
+ /**
241
+ * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
242
+ */
243
+ public function testReverseTransformDisallowsLeadingExtraCharacters ()
244
+ {
245
+ $ transformer = new PercentToLocalizedStringTransformer ();
246
+
247
+ $ transformer ->reverseTransform ('foo123 ' );
248
+ }
249
+
250
+ /**
251
+ * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
252
+ * @expectedExceptionMessage The number contains unrecognized characters: "foo3"
253
+ */
254
+ public function testReverseTransformDisallowsCenteredExtraCharacters ()
255
+ {
256
+ $ transformer = new PercentToLocalizedStringTransformer ();
257
+
258
+ $ transformer ->reverseTransform ('12foo3 ' );
259
+ }
260
+
261
+ /**
262
+ * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
263
+ * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
264
+ * @requires extension mbstring
265
+ */
266
+ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte ()
267
+ {
268
+ // Since we test against other locales, we need the full implementation
269
+ IntlTestHelper::requireFullIntl ($ this , false );
270
+
271
+ \Locale::setDefault ('ru ' );
272
+
273
+ $ transformer = new PercentToLocalizedStringTransformer ();
274
+
275
+ $ transformer ->reverseTransform ("12 \xc2\xa0345,67foo8 " );
276
+ }
277
+
278
+ /**
279
+ * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
280
+ * @expectedExceptionMessage The number contains unrecognized characters: "foo"
281
+ */
282
+ public function testReverseTransformDisallowsTrailingExtraCharacters ()
283
+ {
284
+ $ transformer = new PercentToLocalizedStringTransformer ();
285
+
286
+ $ transformer ->reverseTransform ('123foo ' );
287
+ }
288
+
289
+ /**
290
+ * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
291
+ * @expectedExceptionMessage The number contains unrecognized characters: "foo"
292
+ * @requires extension mbstring
293
+ */
294
+ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte ()
295
+ {
296
+ // Since we test against other locales, we need the full implementation
297
+ IntlTestHelper::requireFullIntl ($ this , false );
298
+
299
+ \Locale::setDefault ('ru ' );
300
+
301
+ $ transformer = new PercentToLocalizedStringTransformer ();
302
+
303
+ $ transformer ->reverseTransform ("12 \xc2\xa0345,678foo " );
304
+ }
239
305
}
0 commit comments