PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/model/miscellaneous/properties.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 79 lines | 62 code | 17 blank | 0 comment | 0 complexity | 8f9da32fe98b032b497dd9a5065554e2 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_key">
  3. <cfset loc.author = model("author").findOne()>
  4. <cfset loc.result = loc.author.key()>
  5. <cfset assert("loc.result IS loc.author.id")>
  6. </cffunction>
  7. <cffunction name="test_key_with_new">
  8. <cfset loc.author = model("author").new(id=1, firstName="Per", lastName="Djurner")>
  9. <cfset loc.result = loc.author.key()>
  10. <cfset assert("loc.result IS 1")>
  11. </cffunction>
  12. <cffunction name="test_setting_and_getting_properties">
  13. <cfset loc.user = model("user").new()>
  14. <cfset loc.args = {}>
  15. <cfset loc.args.Address = "1313 mockingbird lane">
  16. <cfset loc.args.City = "deerfield beach">
  17. <cfset loc.args.Fax = "9545551212">
  18. <cfset loc.args.FirstName = "anthony">
  19. <cfset loc.args.LastName = "Petruzzi">
  20. <cfset loc.args.Password = "it's a secret">
  21. <cfset loc.args.Phone = "9544826106">
  22. <cfset loc.args.State = "fl">
  23. <cfset loc.args.UserName = "tonypetruzzi">
  24. <cfset loc.args.ZipCode = "33441">
  25. <cfset loc.args.Id = "">
  26. <cfset loc.args.birthday = "11/01/1975">
  27. <cfset loc.args.birthdaymonth = "11">
  28. <cfset loc.args.birthdayyear = "1975">
  29. <cfset loc.user.setProperties(loc.args)>
  30. <cfset loc.properties = loc.user.properties()>
  31. <cfloop collection="#loc.properties#" item="loc.i">
  32. <cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
  33. </cfloop>
  34. <cfset loc.args.FirstName = "per">
  35. <cfset loc.args.LastName = "djurner">
  36. <cfset loc.user.setproperties(firstname="per", lastname="djurner")>
  37. <cfset loc.properties = loc.user.properties()>
  38. <cfloop collection="#loc.properties#" item="loc.i">
  39. <cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
  40. </cfloop>
  41. <cfset loc.args.FirstName = "chris">
  42. <cfset loc.args.LastName = "peters">
  43. <cfset loc.args.ZipCode = "33333">
  44. <cfset loc.params = {}>
  45. <cfset loc.params.lastname = "peters">
  46. <cfset loc.params.zipcode = "33333">
  47. <cfset loc.user.setproperties(firstname="chris", properties=loc.params)>
  48. <cfset loc.properties = loc.user.properties()>
  49. <cfloop collection="#loc.properties#" item="loc.i">
  50. <cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
  51. </cfloop>
  52. </cffunction>
  53. <cffunction name="test_setting_and_getting_properties_with_named_arguments">
  54. <cfset loc.author = model("author").findOne()>
  55. <cfset loc.author.setProperties(firstName="a", lastName="b")>
  56. <cfset loc.result = loc.author.properties()>
  57. <cfset loc.compareWith.id = loc.author.key()>
  58. <cfset loc.compareWith.firstName = "a">
  59. <cfset loc.compareWith.lastName = "b">
  60. <cfset assert("loc.result.toString() IS loc.compareWith.toString()")>
  61. </cffunction>
  62. </cfcomponent>