PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/model/miscellaneous/setPagination.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 43 lines | 35 code | 8 blank | 0 comment | 0 complexity | a32b72c1616558b995796daca7730529 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.user = model("user")>
 5	</cffunction>
 6
 7	<cffunction name="test_only_totalRecords">
 8		<cfset loc.user.setPagination(100)>
 9		<cfset assert_pagination(handle="query", totalRecords=100)>
10	</cffunction>
11	
12	<cffunction name="test_all_arguments">
13		<cfset loc.user.setPagination(1000, 4, 50, "pageTest")>
14		<cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=4, perPage=50)>
15	</cffunction>
16	
17	<cffunction name="test_totalRecords_less_than_zero">
18		<cfset loc.user.setPagination(-5, 4, 50, "pageTest")>
19		<cfset assert_pagination(handle="pageTest", totalRecords=0, currentPage=1, perPage=50)>
20	</cffunction>
21	
22	<cffunction name="test_currentPage_less_than_one">
23		<cfset loc.user.setPagination(1000, -4, 50, "pageTest")>
24		<cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=1, perPage=50)>
25	</cffunction>
26	
27	<cffunction name="test_numeric_arguments_must_be_integers">
28		<cfset loc.user.setPagination(1000.9998, 5.876, 50.847, "pageTest")>
29		<cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=5, perPage=50)>
30	</cffunction>
31
32	<cffunction name="assert_pagination">
33		<cfargument name="handle" type="string" required="true">
34		<cfset loc.args = arguments>
35		<cfset assert('StructKeyExists(request.wheels, loc.args.handle)')>
36		<cfset loc.p = request.wheels[loc.args.handle]>
37		<cfset StructDelete(loc.args, "handle", false)>
38		<cfloop collection="#loc.args#" item="loc.i">
39			<cfset assert('loc.p[loc.i] eq loc.args[loc.i]')>
40		</cfloop>
41	</cffunction>
42
43</cfcomponent>