PageRenderTime 15ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/model/calculations/sum.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 38 lines | 31 code | 7 blank | 0 comment | 0 complexity | c133e2ea985af5422772240edd8c356b MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_sum">
  3. <cfset loc.result = model("post").sum(property="views")>
  4. <cfset assert("loc.result IS 13")>
  5. </cffunction>
  6. <cffunction name="test_sum_with_where">
  7. <cfset loc.author = model("author").findOne(where="lastName='Djurner'")>
  8. <cfset loc.result = model("post").sum(property="views", where="authorid=#loc.author.id#")>
  9. <cfset assert("loc.result IS 10")>
  10. </cffunction>
  11. <cffunction name="test_sum_with_non_matching_where">
  12. <cfset loc.result = model("post").sum(property="views", where="id=0")>
  13. <cfset assert("loc.result IS ''")>
  14. </cffunction>
  15. <cffunction name="test_sum_with_distinct">
  16. <cfset loc.result = model("post").sum(property="views", distinct=true)>
  17. <cfset assert("loc.result IS 8")>
  18. </cffunction>
  19. <cffunction name="test_sum_with_ifNull">
  20. <cfset loc.result = model("post").sum(property="views", where="id=0", ifNull=0)>
  21. <cfset assert("loc.result IS 0")>
  22. </cffunction>
  23. <cffunction name="test_sum_with_include_soft_deletes">
  24. <cftransaction action="begin">
  25. <cfset loc.post = model("Post").deleteAll(transaction="none")>
  26. <cfset loc.sum = model("Post").sum(property="views", includeSoftDeletes=true)>
  27. <cftransaction action="rollback" />
  28. </cftransaction>
  29. <cfset assert('loc.sum eq 13')>
  30. </cffunction>
  31. </cfcomponent>