/wheels/tests/model/crud/order.cfc

http://cfwheels.googlecode.com/ · ColdFusion CFScript · 38 lines · 30 code · 8 blank · 0 comment · 0 complexity · 2983fb4f4166094de3240cbea302a36c MD5 · raw file

  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_order_clause_no_sort">
  3. <cfset loc.result = model("author").findOne(order="lastName")>
  4. <cfset assert("loc.result.lastName IS 'Amiri'")>
  5. </cffunction>
  6. <cffunction name="test_order_clause_asc_sort">
  7. <cfset loc.result = model("author").findOne(order="lastName ASC")>
  8. <cfset assert("loc.result.lastName IS 'Amiri'")>
  9. </cffunction>
  10. <cffunction name="test_order_clause_desc_sort">
  11. <cfset loc.result = model("author").findOne(order="lastName DESC")>
  12. <cfset assert("loc.result.lastName IS 'Riera'")>
  13. </cffunction>
  14. <cffunction name="test_order_clause_with_include">
  15. <cfset loc.result = model("post").findAll(include="comments", order="createdAt DESC,id DESC,name")>
  16. <cfset assert("loc.result['title'][1] IS 'Title for fourth test post'")>
  17. </cffunction>
  18. <cffunction name="test_order_clause_with_include_and_identical_columns">
  19. <cfset loc.result = model("post").findAll(include="comments", order="createdAt,createdAt")>
  20. <cfset assert("loc.result['title'][1] IS 'Title for first test post'")>
  21. </cffunction>
  22. <cffunction name="test_order_clause_with_paginated_include_and_identical_columns">
  23. <cfset loc.result = model("post").findAll(page=1, perPage=3, include="comments", order="createdAt,createdAt")>
  24. <cfset assert("loc.result['title'][1] IS 'Title for first test post'")>
  25. </cffunction>
  26. <cffunction name="test_order_clause_with_paginated_include_and_identical_columns_desc_sort_with_specified_table_names">
  27. <cfset loc.result = model("post").findAll(page=1, perPage=3, include="comments", order="posts.createdAt DESC,posts.id DESC,comments.createdAt")>
  28. <cfset assert("loc.result['title'][1] IS 'Title for fourth test post'")>
  29. </cffunction>
  30. </cfcomponent>