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

/wheels/tests/model/callbacks/beforeValidation.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 23 lines | 18 code | 5 blank | 0 comment | 0 complexity | fd362a41cd740e5834c5462abd130828 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset model("tag").$registerCallback(type="beforeValidation", 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="beforeValidation")>
11	</cffunction>
12
13	<cffunction name="test_saving_object">
14		<cfset loc.obj.save()>
15		<cfset assert("StructKeyExists(loc.obj, 'setByCallback')")>
16	</cffunction>
17
18	<cffunction name="test_saving_object_without_callbacks">
19		<cfset loc.obj.save(callbacks=false, transaction="rollback")>
20		<cfset assert("NOT StructKeyExists(loc.obj, 'setByCallback')")>
21	</cffunction>
22
23</cfcomponent>