PageRenderTime 363ms CodeModel.GetById 181ms app.highlight 1ms RepoModel.GetById 180ms app.codeStats 0ms

/wheels/tests/model/callbacks/beforeCreateAndbeforeUpdate.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 23 lines | 19 code | 4 blank | 0 comment | 0 complexity | e3e441de9f9d35e8d93341cfea9476a9 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="teardown">
 4		<cfset model("tag").$clearCallbacks(type="beforeCreate,beforeUpdate")>
 5	</cffunction>
 6
 7	<cffunction name="test_existing_object">
 8		<cfset model("tag").$registerCallback(type="beforeCreate", methods="callbackThatSetsProperty")>
 9		<cfset model("tag").$registerCallback(type="beforeUpdate", methods="callbackThatReturnsFalse")>
10		<cfset loc.obj = model("tag").findOne()>
11		<cfset loc.obj.name = "somethingElse">
12		<cfset loc.obj.save()>
13		<cfset assert("NOT StructKeyExists(loc.obj, 'setByCallback')")>
14	</cffunction>
15	
16	<cffunction name="test_new_object">
17		<cfset model("tag").$registerCallback(type="beforeUpdate", methods="callbackThatSetsProperty")>
18		<cfset model("tag").$registerCallback(type="beforeCreate", methods="callbackThatReturnsFalse")>
19		<cfset loc.obj = model("tag").create()>
20		<cfset assert("NOT StructKeyExists(loc.obj, 'setByCallback')")>
21	</cffunction>
22	
23</cfcomponent>