PageRenderTime 62ms CodeModel.GetById 21ms app.highlight 0ms RepoModel.GetById 20ms app.codeStats 0ms

/wheels/tests/model/crud/order.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 38 lines | 30 code | 8 blank | 0 comment | 0 complexity | 2983fb4f4166094de3240cbea302a36c MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_order_clause_no_sort">
 4		<cfset loc.result = model("author").findOne(order="lastName")>
 5		<cfset assert("loc.result.lastName IS 'Amiri'")>
 6	</cffunction>
 7
 8	<cffunction name="test_order_clause_asc_sort">
 9		<cfset loc.result = model("author").findOne(order="lastName ASC")>
10		<cfset assert("loc.result.lastName IS 'Amiri'")>
11	</cffunction>
12
13	<cffunction name="test_order_clause_desc_sort">
14		<cfset loc.result = model("author").findOne(order="lastName DESC")>
15		<cfset assert("loc.result.lastName IS 'Riera'")>
16	</cffunction>
17
18	<cffunction name="test_order_clause_with_include">
19		<cfset loc.result = model("post").findAll(include="comments", order="createdAt DESC,id DESC,name")>
20		<cfset assert("loc.result['title'][1] IS 'Title for fourth test post'")>
21	</cffunction>
22
23	<cffunction name="test_order_clause_with_include_and_identical_columns">
24		<cfset loc.result = model("post").findAll(include="comments", order="createdAt,createdAt")>
25		<cfset assert("loc.result['title'][1] IS 'Title for first test post'")>
26	</cffunction>
27
28	<cffunction name="test_order_clause_with_paginated_include_and_identical_columns">
29		<cfset loc.result = model("post").findAll(page=1, perPage=3, include="comments", order="createdAt,createdAt")>
30		<cfset assert("loc.result['title'][1] IS 'Title for first test post'")>
31	</cffunction>
32
33	<cffunction name="test_order_clause_with_paginated_include_and_identical_columns_desc_sort_with_specified_table_names">
34		<cfset loc.result = model("post").findAll(page=1, perPage=3, include="comments", order="posts.createdAt DESC,posts.id DESC,comments.createdAt")>
35		<cfset assert("loc.result['title'][1] IS 'Title for fourth test post'")>
36	</cffunction>
37
38</cfcomponent>