/wheels/tests/model/calculations/sum.cfc
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
- <cfcomponent extends="wheelsMapping.Test">
-
- <cffunction name="test_sum">
- <cfset loc.result = model("post").sum(property="views")>
- <cfset assert("loc.result IS 13")>
- </cffunction>
-
- <cffunction name="test_sum_with_where">
- <cfset loc.author = model("author").findOne(where="lastName='Djurner'")>
- <cfset loc.result = model("post").sum(property="views", where="authorid=#loc.author.id#")>
- <cfset assert("loc.result IS 10")>
- </cffunction>
-
- <cffunction name="test_sum_with_non_matching_where">
- <cfset loc.result = model("post").sum(property="views", where="id=0")>
- <cfset assert("loc.result IS ''")>
- </cffunction>
-
- <cffunction name="test_sum_with_distinct">
- <cfset loc.result = model("post").sum(property="views", distinct=true)>
- <cfset assert("loc.result IS 8")>
- </cffunction>
-
- <cffunction name="test_sum_with_ifNull">
- <cfset loc.result = model("post").sum(property="views", where="id=0", ifNull=0)>
- <cfset assert("loc.result IS 0")>
- </cffunction>
-
- <cffunction name="test_sum_with_include_soft_deletes">
- <cftransaction action="begin">
- <cfset loc.post = model("Post").deleteAll(transaction="none")>
- <cfset loc.sum = model("Post").sum(property="views", includeSoftDeletes=true)>
- <cftransaction action="rollback" />
- </cftransaction>
- <cfset assert('loc.sum eq 13')>
- </cffunction>
-
- </cfcomponent>