8000 Merge branch '3.4' into 4.1 · symfony/symfony@a4bc4ac · GitHub
[go: up one dir, main page]

Skip to content

Commit a4bc4ac

Browse files
Merge branch '3.4' into 4.1
* 3.4: typo add a test case [Form] Handle all case variants of "nan" when parsing a number
2 parents bce7748 + 6c3c47e commit a4bc4ac

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function reverseTransform($value)
146146
return;
147147
}
148148

149-
if ('NaN' === $value) {
149+
if (\in_array($value, array('NaN', 'NAN', 'nan'), true)) {
150150
throw new TransformationFailedException('"NaN" is not a valid number');
151151
}
152152

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,24 +514,24 @@ public function testReverseTransformExpectsValidNumber()
514514

515515
/**
516516
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
517+
* @dataProvider nanRepresentationProvider
517518
*
518519
* @see https://github.com/symfony/symfony/issues/3161
519520
*/
520-
public function testReverseTransformDisallowsNaN()
521+
public function testReverseTransformDisallowsNaN($nan)
521522
{
522523
$transformer = new NumberToLocalizedStringTransformer();
523524

524-
$transformer->reverseTransform('NaN');
525+
$transformer->reverseTransform($nan);
525526
}
526527

527-
/**
528-
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
529-
*/
530-
public function testReverseTransformDisallowsNaN2()
528+
public function nanRepresentationProvider()
531529
{
532-
$transformer = new NumberToLocalizedStringTransformer();
533-
534-
$transformer->reverseTransform('nan');
530+
return array(
531+
array('nan'),
532+
array('NaN'), // see https://github.com/symfony/symfony/issues/3161
533+
array('NAN'),
534+
);
535535
}
536536

537537
/**

src/Symfony/Component/Validator/Context/ExecutionContextInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getValidator();
112112
* Returns the currently validated object.
113113
*
114114
* If the validator is currently validating a class constraint, the
115-
* object of that class is returned. If it is a validating a property or
115+
* object of that class is returned. If it is validating a property or
116116
* getter constraint, the object that the property/getter belongs to is
117117
* returned.
118118
*

0 commit comments

Comments
 (0)
0