silverstripe-framework/tests/php/ORM/DecimalTest.php

43 lines
1.1 KiB
PHP
Raw Normal View History

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