PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/model/callbacks/beforeUpdate.cfc

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