silverstripe-framework/tests/forms/NumericFieldTest.php
Will Rossiter a99dbae012 FIX: NumericField should work with numbers like 54,6
Fixes http://open.silverstripe.org/ticket/5577.

Uses Zend_Locale_Format::isNumber(). Includes unit test for NumericField. Does not include testing work on DBField underlying NumericField to ensure that works consistently.
2013-05-11 22:51:39 +12:00

37 lines
843 B
PHP

<?php
/**
* @package framework
* @subpackage tests
*/
class NumericFieldTest extends SapphireTest {
protected $usesDatabase = false;
public function testValidator() {
i18n::set_locale('en_US');
$field = new NumericField('Number');
$field->setValue('12.00');
$validator = new RequiredFields('Number');
$this->assertTrue($field->validate($validator));
$field->setValue('12,00');
$this->assertFalse($field->validate($validator));
$field->setValue('0');
$this->assertTrue($field->validate($validator));
$field->setValue(false);
$this->assertFalse($field->validate($validator));
i18n::set_locale('de_DE');
$field->setValue('12,00');
$validator = new RequiredFields();
$this->assertTrue($field->validate($validator));
$field->setValue('12.00');
$this->assertFalse($field->validate($validator));
}
}