PageRenderTime 283ms CodeModel.GetById 120ms app.highlight 1ms RepoModel.GetById 160ms app.codeStats 0ms

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