/wheels/tests/model/callbacks/beforeCreate.cfc
http://cfwheels.googlecode.com/ · ColdFusion CFScript · 21 lines · 16 code · 5 blank · 0 comment · 0 complexity · 42970f67301ca13fdc205a71cd14c4c7 MD5 · raw file
- <cfcomponent extends="wheelsMapping.Test">
-
- <cffunction name="setup">
- <cfset model("tag").$registerCallback(type="beforeCreate", methods="callbackThatSetsProperty, callbackThatReturnsFalse")>
- </cffunction>
-
- <cffunction name="teardown">
- <cfset model("tag").$clearCallbacks(type="beforeCreate")>
- </cffunction>
-
- <cffunction name="test_new_object">
- <cfset loc.obj = model("tag").create()>
- <cfset assert("StructKeyExists(loc.obj, 'setByCallback')")>
- </cffunction>
-
- <cffunction name="test_new_object_with_skipped_callback">
- <cfset loc.obj = model("tag").create(name="mustSetAtLeastOnePropertyOrCreateFails", transaction="rollback", callbacks=false)>
- <cfset assert("NOT StructKeyExists(loc.obj, 'setByCallback')")>
- </cffunction>
-
- </cfcomponent>