PageRenderTime 203ms CodeModel.GetById 100ms app.highlight 1ms RepoModel.GetById 100ms 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
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_sum">
 4		<cfset loc.result = model("post").sum(property="views")>
 5		<cfset assert("loc.result IS 13")>
 6	</cffunction>
 7
 8	<cffunction name="test_sum_with_where">
 9		<cfset loc.author = model("author").findOne(where="lastName='Djurner'")>
10		<cfset loc.result = model("post").sum(property="views", where="authorid=#loc.author.id#")>
11		<cfset assert("loc.result IS 10")>
12	</cffunction>
13
14	<cffunction name="test_sum_with_non_matching_where">
15		<cfset loc.result = model("post").sum(property="views", where="id=0")>
16		<cfset assert("loc.result IS ''")>
17	</cffunction>
18
19	<cffunction name="test_sum_with_distinct">
20		<cfset loc.result = model("post").sum(property="views", distinct=true)>
21		<cfset assert("loc.result IS 8")>
22	</cffunction>
23
24	<cffunction name="test_sum_with_ifNull">
25		<cfset loc.result = model("post").sum(property="views", where="id=0", ifNull=0)>
26		<cfset assert("loc.result IS 0")>
27	</cffunction>
28
29	<cffunction name="test_sum_with_include_soft_deletes">
30		<cftransaction action="begin">
31			<cfset loc.post = model("Post").deleteAll(transaction="none")>
32			<cfset loc.sum = model("Post").sum(property="views", includeSoftDeletes=true)>
33			<cftransaction action="rollback" />
34		</cftransaction>
35		<cfset assert('loc.sum eq 13')>
36	</cffunction>
37
38</cfcomponent>