diff --git a/tests/php/Forms/FormTest.php b/tests/php/Forms/FormTest.php
index b4bbee79f..bc2a12966 100644
--- a/tests/php/Forms/FormTest.php
+++ b/tests/php/Forms/FormTest.php
@@ -1052,8 +1052,8 @@ class FormTest extends FunctionalTest
);
$this->assertContains(
- 'clean($body),
'Our reloaded form should contain a SomeFrenchNumericField with the value "9 876,5432"'
);
@@ -1064,8 +1064,8 @@ class FormTest extends FunctionalTest
);
$this->assertContains(
- 'clean($body),
'Our reloaded form should contain a SomeFrenchMoneyField[Amount] with the value "9 876,54"'
);
@@ -1108,4 +1108,22 @@ class FormTest extends FunctionalTest
new FieldList()
);
}
+ /**
+ * In some cases and locales, validation expects non-breaking spaces.
+ * This homogenises narrow and regular NBSPs to a regular space character
+ *
+ * @param string $input
+ * @return string The input value, with all non-breaking spaces replaced with spaces
+ */
+ protected function clean($input)
+ {
+ return str_replace(
+ [
+ html_entity_decode(' ', null, 'UTF-8'),
+ html_entity_decode(' ', null, 'UTF-8'), // narrow non-breaking space
+ ],
+ ' ',
+ trim($input)
+ );
+ }
}
diff --git a/tests/php/Forms/NumericFieldTest.php b/tests/php/Forms/NumericFieldTest.php
index 622c3783b..f8b146e08 100644
--- a/tests/php/Forms/NumericFieldTest.php
+++ b/tests/php/Forms/NumericFieldTest.php
@@ -13,16 +13,23 @@ class NumericFieldTest extends SapphireTest
/**
* In some cases and locales, validation expects non-breaking spaces.
+ * This homogenises narrow and regular NBSPs to a regular space character
*
* Duplicates non-public NumericField::clean method
*
* @param string $input
- * @return string The input value, with all spaces replaced with non-breaking spaces
+ * @return string The input value, with all non-breaking spaces replaced with spaces
*/
protected function clean($input)
{
- $nbsp = html_entity_decode(' ', null, 'UTF-8');
- return str_replace(' ', $nbsp, trim($input));
+ return str_replace(
+ [
+ html_entity_decode(' ', null, 'UTF-8'),
+ html_entity_decode(' ', null, 'UTF-8'), // narrow non-breaking space
+ ],
+ ' ',
+ trim($input)
+ );
}
/**