function testWriteToDataObject() { $obj = new MoneyTest_DataObject(); $m = new Money(); $m->setValue(array('Currency' => 'EUR', 'Amount' => 1.23)); $obj->MyMoney = $m; $obj->write(); $this->assertEquals('EUR', DB::query(sprintf('SELECT "MyMoneyCurrency" FROM "MoneyTest_DataObject" WHERE "ID" = %d', $obj->ID))->value()); $this->assertEquals('1.23', DB::query(sprintf('SELECT "MyMoneyAmount" FROM "MoneyTest_DataObject" WHERE "ID" = %d', $obj->ID))->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()); }