PageRenderTime 414ms CodeModel.GetById 221ms app.highlight 2ms RepoModel.GetById 189ms app.codeStats 0ms

/wheels/tests/view/formsdateplain/DateTimeSelectTags.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 84 lines | 76 code | 8 blank | 0 comment | 0 complexity | 93058a50f5956db48b7ba1a3100b5e76 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset pkg.controller = controller("dummy")>
 5		<cfset result = "">
 6		<cfset results = {}>
 7		<cfset loc.controller = controller(name="dummy")>
 8		<cfset loc.args = {}>
 9		<cfset loc.args.label = false>
10	</cffunction>
11
12	<cffunction name="testNoLabels">
13		<cfset result = pkg.controller.dateTimeSelectTags(name="theName", label=false)>
14		<cfset assert("result Does Not Contain 'label'")>
15	</cffunction>
16
17	<cffunction name="testSameLabels">
18		<cfset var loc = {}>
19		<cfset loc.str = pkg.controller.dateTimeSelectTags(name="theName", label="lblText")>
20		<cfset loc.sub = "lblText">
21		<cfset result = (Len(loc.str)-Len(Replace(loc.str,loc.sub,"","all")))/Len(loc.sub)>
22		<cfset assert("result IS 6")>
23	</cffunction>
24
25	<cffunction name="testSplittingLabels">
26		<cfset result = pkg.controller.dateTimeSelectTags(name="theName", label="labelMonth,labelDay,labelYear,labelHour,labelMinute,labelSecond")>
27		<cfset assert("result Contains 'labelDay' AND result Contains 'labelSecond'")>
28	</cffunction>
29
30	<cffunction name="test_dateTimeSelectTags_blank_included_boolean">
31		<cfset loc.args.name = "dateselector">
32		<cfset loc.args.includeBlank = "true">
33		<cfset loc.args.selected = "">
34		<cfset loc.args.startyear = "2000">
35		<cfset loc.args.endyear = "1990">
36		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
37		<cfset loc.e = '<option selected="selected" value=""></option>'>
38		<cfset assert("loc.r contains loc.e")>
39		<cfset loc.args.selected = "01/02/2000">
40		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
41		<cfset debug('loc.r', false)>
42		<cfset loc.e1 = '<option selected="selected" value="1">January</option>'>
43		<cfset loc.e2 = '<option selected="selected" value="2">2</option>'>
44		<cfset loc.e3 = '<option selected="selected" value="2000">2000</option>'>
45		<cfset assert("loc.r contains loc.e1 && loc.r contains loc.e2 && loc.r contains loc.e3")>
46	</cffunction>
47
48	<cffunction name="test_dateTimeSelectTags_blank_included_string">
49		<cfset loc.args.name = "dateselector">
50		<cfset loc.args.includeBlank = "--Month--">
51		<cfset loc.args.selected = "">
52		<cfset loc.args.startyear = "2000">
53		<cfset loc.args.endyear = "1990">
54		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
55		<cfset loc.e = '<option selected="selected" value="">--Month--</option>'>
56		<cfset assert("loc.r contains loc.e")>
57		<cfset loc.args.selected = "01/02/2000">
58		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
59		<cfset debug('loc.r', false)>
60		<cfset loc.e1 = '<option selected="selected" value="1">January</option>'>
61		<cfset loc.e2 = '<option selected="selected" value="2">2</option>'>
62		<cfset loc.e3 = '<option selected="selected" value="2000">2000</option>'>
63		<cfset assert("loc.r contains loc.e1 && loc.r contains loc.e2 && loc.r contains loc.e3")>
64	</cffunction>
65
66	<cffunction name="test_dateTimeSelectTags_blank_not_included">
67		<cfset loc.args.name = "dateselector">
68		<cfset loc.args.includeBlank = "false">
69		<cfset loc.args.selected = "">
70		<cfset loc.args.startyear = "2000">
71		<cfset loc.args.endyear = "1990">
72		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
73		<cfset loc.e = '<option selected="selected" value=""></option>'>
74		<cfset assert("loc.r does not contain loc.e")>
75		<cfset loc.args.selected = "01/02/2000">
76		<cfset loc.r = loc.controller.dateTimeSelectTags(argumentcollection=loc.args)>
77		<cfset debug('loc.r', false)>
78		<cfset loc.e1 = '<option selected="selected" value="1">January</option>'>
79		<cfset loc.e2 = '<option selected="selected" value="2">2</option>'>
80		<cfset loc.e3 = '<option selected="selected" value="2000">2000</option>'>
81		<cfset assert("loc.r contains loc.e1 && loc.r contains loc.e2 && loc.r contains loc.e3")>
82	</cffunction>
83
84</cfcomponent>