mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added test for lazy-loading edge-case in Money field.
This commit is contained in:
parent
eb583c5f14
commit
9ba26a04c4
@ -17,6 +17,7 @@ class MoneyTest extends SapphireTest {
|
|||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
'MoneyTest_DataObject',
|
'MoneyTest_DataObject',
|
||||||
|
'MoneyTest_SubClass',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testMoneyFieldsReturnedAsObjects() {
|
public function testMoneyFieldsReturnedAsObjects() {
|
||||||
@ -268,6 +269,15 @@ class MoneyTest extends SapphireTest {
|
|||||||
))->value()
|
))->value()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMoneyLazyLoading() {
|
||||||
|
// Get the object, ensuring that MyOtherMoney will be lazy loaded
|
||||||
|
$id = $this->idFromFixture('MoneyTest_SubClass', 'test2');
|
||||||
|
$obj = MoneyTest_DataObject::get()->byID($id);
|
||||||
|
|
||||||
|
$this->assertEquals('£2.46', $obj->obj('MyOtherMoney')->Nice());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoneyTest_DataObject extends DataObject implements TestOnly {
|
class MoneyTest_DataObject extends DataObject implements TestOnly {
|
||||||
@ -277,3 +287,9 @@ class MoneyTest_DataObject extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
class MoneyTest_SubClass extends MoneyTest_DataObject implements TestOnly {
|
||||||
|
static $db = array(
|
||||||
|
'MyOtherMoney' => 'Money',
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -2,3 +2,7 @@ MoneyTest_DataObject:
|
|||||||
test1:
|
test1:
|
||||||
MyMoneyCurrency: EUR
|
MyMoneyCurrency: EUR
|
||||||
MyMoneyAmount: 1.23
|
MyMoneyAmount: 1.23
|
||||||
|
MoneyTest_SubClass:
|
||||||
|
test2:
|
||||||
|
MyOtherMoneyCurrency: GBP
|
||||||
|
MyOtherMoneyAmount: 2.46
|
Loading…
Reference in New Issue
Block a user