PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/wheels/tests/model/properties/defaults.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 30 lines | 25 code | 5 blank | 0 comment | 0 complexity | 7b5f1fa98fcf7bc54590d9fa83d1fc3c MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_new_model_with_property_defaults">
 4		<cfset loc.author = model("Author").new()>
 5		<cfset assert('StructKeyExists(loc.author, "firstName") and loc.author.firstName eq "Dave"')>
 6	</cffunction>
 7
 8	<cffunction name="test_new_model_with_property_defaults_set_to_blank">
 9		<cfset loc.author = model("Author").new()>
10		<cfset assert('StructKeyExists(loc.author, "lastName") and loc.author.lastName eq ""')>
11	</cffunction>
12
13	<cffunction name="test_database_defaults_load_after_create">
14		<cftransaction action="begin">
15			<cfset loc.user = model("UserBlank").create(username="The Dude", password="doodle", firstName="The", lastName="Dude", reload=true)>
16			<cftransaction action="rollback" />
17		</cftransaction>
18		<cfset assert('StructKeyExists(loc.user, "birthTime") and TimeFormat(loc.user.birthTime, "HH:mm:ss") eq "18:26:08"')>
19	</cffunction>
20
21	<cffunction name="test_database_defaults_load_after_save">
22		<cftransaction action="begin">
23			<cfset loc.user = model("UserBlank").new(username="The Dude", password="doodle", firstName="The", lastName="Dude")>
24			<cfset loc.user.save(reload=true)>
25			<cftransaction action="rollback" />
26		</cftransaction>
27		<cfset assert('StructKeyExists(loc.user, "birthTime") and TimeFormat(loc.user.birthTime, "HH:mm:ss") eq "18:26:08"')>
28	</cffunction>
29
30</cfcomponent>