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