PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/wheels/tests/model/sql/whereclause.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 57 lines | 49 code | 8 blank | 0 comment | 0 complexity | 13cfce8471f484eab0aff412d8aa83d9 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_numeric_operators">
 4		<cfset operators = "=,<>,!=,<,<=,!<,>,>=,!>">
 5		<cfloop list="#operators#" index="i">
 6			<cfset check = "Len(result[2]) IS (11+#Len(i)#) AND ArrayLen(result) IS 3 AND result[3].type IS 'cf_sql_integer' AND Right(result[2], #Len(i)#) IS '#i#'">
 7			<cfset result = model("author").$whereClause(where="id#i#0")>
 8			<cfset assert(check)>
 9			<cfset result = model("author").$whereClause(where="id#i# 11")>
10			<cfset assert(check)>
11			<cfset result = model("author").$whereClause(where="id #i#999")>
12			<cfset assert(check)>
13		</cfloop>
14	</cffunction>
15
16	<cffunction name="test_in_like_operators">
17			<cfset result = model("author").$whereClause(where="id IN (1,2,3)")>
18			<cfset assert("Right(result[2], 2) IS 'IN'")>
19			<cfset result = model("author").$whereClause(where="id NOT IN (1,2,3)")>
20			<cfset assert("Right(result[2], 6) IS 'NOT IN'")>
21			<cfset result = model("author").$whereClause(where="lastName LIKE 'Djurner'")>
22			<cfset assert("Right(result[2], 4) IS 'LIKE'")>
23			<cfset result = model("author").$whereClause(where="lastName NOT LIKE 'Djurner'")>
24			<cfset assert("Right(result[2], 8) IS 'NOT LIKE'")>
25	</cffunction>
26
27	<cffunction name="test_floats">
28		<cfset result = model("post").$whereClause(where="averagerating IN(3.6,3.2)")>
29		<cfset assert('arraylen(result) gte 4')>
30		<cfset assert('isstruct(result[4])')>
31		<cfset assert('result[4].datatype eq "float" OR result[4].datatype eq "float8" OR result[4].datatype eq "double" OR result[4].datatype eq "number"')>
32		<cfset result = model("post").$whereClause(where="averagerating NOT IN(3.6,3.2)")>
33		<cfset assert('arraylen(result) gte 4')>
34		<cfset assert('isstruct(result[4])')>
35		<cfset assert('result[4].datatype eq "float" OR result[4].datatype eq "float8" OR result[4].datatype eq "double" OR result[4].datatype eq "number"')>
36		<cfset result = model("post").$whereClause(where="averagerating = 3.6")>
37		<cfset assert('arraylen(result) gte 4')>
38		<cfset assert('isstruct(result[4])')>
39		<cfset assert('result[4].datatype eq "float" OR result[4].datatype eq "float8" OR result[4].datatype eq "double" OR result[4].datatype eq "number"')>
40	</cffunction>
41
42	<cffunction name="test_is_null">
43		<cfset result = model("post").$whereClause(where="averagerating IS NULL")>
44		<cfset assert('arraylen(result) gte 4')>
45		<cfset assert('isstruct(result[4])')>
46		<cfset result = model("post").$whereClause(where="averagerating IS NOT NULL")>
47		<cfset assert('arraylen(result) gte 4')>
48		<cfset assert('isstruct(result[4])')>
49		<cfset assert('result[4].datatype eq "float" OR result[4].datatype eq "float8" OR result[4].datatype eq "double" OR result[4].datatype eq "number"')>
50	</cffunction>
51
52	<cffunction name="test_should_allow">
53
54	</cffunction>
55
56
57</cfcomponent>