2010-04-13 02:10:13 +00:00
|
|
|
<?php
|
2016-06-15 16:03:16 +12:00
|
|
|
|
2016-10-14 14:30:05 +13:00
|
|
|
namespace SilverStripe\ORM\Tests;
|
|
|
|
|
2016-08-19 10:51:35 +12:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
2010-04-13 02:10:13 +00:00
|
|
|
class DecimalTest extends SapphireTest {
|
|
|
|
|
2013-03-21 19:48:54 +01:00
|
|
|
protected static $fixture_file = 'DecimalTest.yml';
|
2010-04-13 02:10:13 +00:00
|
|
|
|
|
|
|
protected $testDataObject;
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2010-04-13 02:10:13 +00:00
|
|
|
protected $extraDataObjects = array(
|
2016-10-14 14:30:05 +13:00
|
|
|
DecimalTest\TestObject::class
|
2010-04-13 02:10:13 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2016-10-14 14:30:05 +13:00
|
|
|
$this->testDataObject = $this->objFromFixture(DecimalTest\TestObject::class, 'test-dataobject');
|
2010-04-13 02:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDefaultValue() {
|
2012-09-27 09:34:00 +12:00
|
|
|
$this->assertEquals($this->testDataObject->MyDecimal1, 0,
|
|
|
|
'Database default for Decimal type is 0');
|
2010-04-13 02:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpecifiedDefaultValue() {
|
2012-09-27 09:34:00 +12:00
|
|
|
$this->assertEquals($this->testDataObject->MyDecimal2, 2.5,
|
|
|
|
'Default value for Decimal type is set to 2.5');
|
2010-04-13 02:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testInvalidSpecifiedDefaultValue() {
|
2012-09-27 09:34:00 +12:00
|
|
|
$this->assertEquals($this->testDataObject->MyDecimal3, 0,
|
|
|
|
'Invalid default value for Decimal type is casted to 0');
|
2010-04-13 02:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpecifiedDefaultValueInDefaultsArray() {
|
2012-09-27 09:34:00 +12:00
|
|
|
$this->assertEquals($this->testDataObject->MyDecimal4, 4,
|
|
|
|
'Default value for Decimal type is set to 4');
|
2010-04-13 02:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|