PageRenderTime 140ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cfset model("tag").$registerCallback(type="beforeValidation", methods="callbackThatSetsProperty,callbackThatReturnsFalse")>
  4. <cfset loc.obj = model("tag").findOne()>
  5. <cfset loc.obj.name = "somethingElse">
  6. </cffunction>
  7. <cffunction name="teardown">
  8. <cfset model("tag").$clearCallbacks(type="beforeValidation")>
  9. </cffunction>
  10. <cffunction name="test_saving_object">
  11. <cfset loc.obj.save()>
  12. <cfset assert("StructKeyExists(loc.obj, 'setByCallback')")>
  13. </cffunction>
  14. <cffunction name="test_saving_object_without_callbacks">
  15. <cfset loc.obj.save(callbacks=false, transaction="rollback")>
  16. <cfset assert("NOT StructKeyExists(loc.obj, 'setByCallback')")>
  17. </cffunction>
  18. </cfcomponent>