function testDataValue() { $f = new CurrencyField('TestField'); $f->setValue('$123.45'); $this->assertEquals($f->dataValue(), 123.45); $f->setValue('-$123.45'); $this->assertEquals($f->dataValue(), -123.45); $f->setValue('$-123.45'); $this->assertEquals($f->dataValue(), -123.45); }
public function testDataValue() { $f = new CurrencyField('TestField'); //tests with default currency symbol settings $f->setValue('$123.45'); $this->assertEquals($f->dataValue(), 123.45); $f->setValue('-$123.45'); $this->assertEquals($f->dataValue(), -123.45); $f->setValue('$-123.45'); $this->assertEquals($f->dataValue(), -123.45); //tests with updated currency symbol setting Config::inst()->update('Currency', 'currency_symbol', '€'); $f->setValue('€123.45'); $this->assertEquals($f->dataValue(), 123.45); $f->setValue('-€123.45'); $this->assertEquals($f->dataValue(), -123.45); $f->setValue('€-123.45'); $this->assertEquals($f->dataValue(), -123.45); }