/wheels/tests/model/crud/group.cfc

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

  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_distinct_works_with_group_by">
  3. <cfset loc.r = model("post").findAll(select="views", distinct=true)>
  4. <cfset assert('loc.r.recordcount eq 3')>
  5. <cfset loc.r = model("post").findAll(select="views", group="views")>
  6. <cfset assert('loc.r.recordcount eq 3')>
  7. </cffunction>
  8. <cffunction name="test_wrong_table_alias_in_group_by_throws_error">
  9. <cfset loc.model = model("post") />
  10. <cfset raised('loc.model.$createSQLFieldList(list="posts.*", include="", renameFields=false, addCalculatedProperties=false)') />
  11. </cffunction>
  12. <cffunction name="test_max_works_with_group_functionality">
  13. <cfset loc.r = model("post").findAll(select="id, authorid, title, MAX(posts.views) AS maxView", group="id, authorid, title")>
  14. <cfset assert('loc.r.recordcount eq 4')>
  15. </cffunction>
  16. <cffunction name="test_group_functionality_works_with_pagination">
  17. <cfset loc.r = model("post").findAll(select="id, authorid, title, MAX(posts.views) AS maxView", group="id, authorid, title", page=1, perPage=2)>
  18. <cfset assert('loc.r.recordcount eq 2')>
  19. </cffunction>
  20. </cfcomponent>