PageRenderTime 283ms CodeModel.GetById 141ms app.highlight 1ms RepoModel.GetById 140ms app.codeStats 0ms

/wheels/tests/view/formsdateobject/DateSelect.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 59 lines | 52 code | 7 blank | 0 comment | 0 complexity | 804f54e6a93b38d568227b1b82b94449 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.controller = controller(name="ControllerWithModel")>
 5		<cfset loc.args = {}>
 6		<cfset loc.args.objectName = "user">
 7		<cfset loc.args.label = false>
 8	</cffunction>
 9
10	<cffunction name="test_dateselect_parsing_and_passed_month">
11		<cfset loc.args.property = "birthday">
12		<cfset loc.args.order = "month">
13		<cfset debug("loc.controller.dateSelect(argumentcollection=loc.args)", false)>
14		<cfset loc.e = dateSelect_month_str(loc.args.property)>
15		<cfset loc.r = loc.controller.dateSelect(argumentcollection=loc.args)>
16		<cfset assert("loc.e eq loc.r")>
17		<cfset loc.args.property = "birthdaymonth">
18		<cfset loc.e = dateSelect_month_str(loc.args.property)>
19		<cfset loc.r = loc.controller.dateSelect(argumentcollection=loc.args)>
20		<cfset assert("loc.e eq loc.r")>
21	</cffunction>
22
23	<cffunction name="dateSelect_month_str">
24		<cfargument name="property" type="string" required="true">
25		<cfreturn '<select id="user-#arguments.property#-month" name="user[#arguments.property#]($month)"><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option selected="selected" value="11">November</option><option value="12">December</option></select>'>
26	</cffunction>
27
28	<cffunction name="test_dateselect_parsing_and_passed_year">
29		<cfset loc.args.property = "birthday">
30		<cfset loc.args.order = "year">
31		<cfset loc.args.startyear = "1973">
32		<cfset loc.args.endyear = "1976">
33		<cfset debug("loc.controller.dateSelect(argumentcollection=loc.args)", false)>
34		<cfset loc.e = dateSelect_year_str(loc.args.property)>
35		<cfset loc.r = loc.controller.dateSelect(argumentcollection=loc.args)>
36		<cfset assert("loc.e eq loc.r")>
37		<cfset loc.args.property = "birthdayyear">
38		<cfset loc.e = dateSelect_year_str(loc.args.property)>
39		<cfset loc.r = loc.controller.dateSelect(argumentcollection=loc.args)>
40		<cfset assert("loc.e eq loc.r")>
41	</cffunction>
42
43	<cffunction name="test_dateselect_year_is_less_than_startyear">
44		<cfset loc.args.property = "birthday">
45		<cfset loc.args.order = "year">
46		<cfset loc.args.startyear = "1976">
47		<cfset loc.args.endyear = "1980">
48		<cfset debug("loc.controller.dateSelect(argumentcollection=loc.args)", false)>
49		<cfset loc.e = '<select id="user-birthday-year" name="user[birthday]($year)"><option selected="selected" value="1975">1975</option><option value="1976">1976</option><option value="1977">1977</option><option value="1978">1978</option><option value="1979">1979</option><option value="1980">1980</option></select>'>
50		<cfset loc.r = loc.controller.dateSelect(argumentcollection=loc.args)>
51		<cfset assert("loc.e eq loc.r")>
52	</cffunction>
53
54	<cffunction name="dateSelect_year_str">
55		<cfargument name="property" type="string" required="true">
56		<cfreturn '<select id="user-#arguments.property#-year" name="user[#arguments.property#]($year)"><option value="1973">1973</option><option value="1974">1974</option><option selected="selected" value="1975">1975</option><option value="1976">1976</option></select>'>
57	</cffunction>
58
59</cfcomponent>