/wheels/tests/model/properties/defaults.cfc

http://cfwheels.googlecode.com/ · ColdFusion CFScript · 30 lines · 25 code · 5 blank · 0 comment · 0 complexity · 7b5f1fa98fcf7bc54590d9fa83d1fc3c MD5 · raw file

  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_new_model_with_property_defaults">
  3. <cfset loc.author = model("Author").new()>
  4. <cfset assert('StructKeyExists(loc.author, "firstName") and loc.author.firstName eq "Dave"')>
  5. </cffunction>
  6. <cffunction name="test_new_model_with_property_defaults_set_to_blank">
  7. <cfset loc.author = model("Author").new()>
  8. <cfset assert('StructKeyExists(loc.author, "lastName") and loc.author.lastName eq ""')>
  9. </cffunction>
  10. <cffunction name="test_database_defaults_load_after_create">
  11. <cftransaction action="begin">
  12. <cfset loc.user = model("UserBlank").create(username="The Dude", password="doodle", firstName="The", lastName="Dude", reload=true)>
  13. <cftransaction action="rollback" />
  14. </cftransaction>
  15. <cfset assert('StructKeyExists(loc.user, "birthTime") and TimeFormat(loc.user.birthTime, "HH:mm:ss") eq "18:26:08"')>
  16. </cffunction>
  17. <cffunction name="test_database_defaults_load_after_save">
  18. <cftransaction action="begin">
  19. <cfset loc.user = model("UserBlank").new(username="The Dude", password="doodle", firstName="The", lastName="Dude")>
  20. <cfset loc.user.save(reload=true)>
  21. <cftransaction action="rollback" />
  22. </cftransaction>
  23. <cfset assert('StructKeyExists(loc.user, "birthTime") and TimeFormat(loc.user.birthTime, "HH:mm:ss") eq "18:26:08"')>
  24. </cffunction>
  25. </cfcomponent>