From 88359b1ba5db05b2dea38ee51059d5e04bf2564f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 16 Mar 2009 13:43:03 +0000 Subject: [PATCH] MINOR Added DataObjectTest->testPopulateDefaults() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73131 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/DataObjectTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/DataObjectTest.php b/tests/DataObjectTest.php index a7daa02a6..fe6e3d539 100644 --- a/tests/DataObjectTest.php +++ b/tests/DataObjectTest.php @@ -595,6 +595,15 @@ class DataObjectTest extends SapphireTest { 'Position' => 'Varchar(100)' )); } + + function testPopulateDefaults() { + $obj = new DataObjectTest_WithDefaults(); + $this->assertEquals( + $obj->MyField, + "Default Value", + "Defaults are populated for in-memory object from \$defaults array" + ); + } } @@ -645,6 +654,16 @@ class DataObjectTest_FunnyFieldNames extends DataObject implements TestOnly { ); } +class DataObjectTest_WithDefaults extends DataObject implements TestOnly { + static $db = array( + 'MyField' => 'Text', + ); + + static $defaults = array( + 'MyField' => 'Default Value', + ); +} + class DataObjectTest_SubTeam extends DataObjectTest_Team implements TestOnly { static $db = array( 'SubclassDatabaseField' => 'Text'