PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/wheels/tests/view/forms/yearSelect.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 57 lines | 50 code | 7 blank | 0 comment | 0 complexity | 02c9776daa72f81635d1064825713258 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.controller = createobject("component", "wheelsMapping.tests._assets.controllers.ControllerWithModel")>
 5		<cfset loc.args= {}>
 6		<cfset loc.args.objectName = "user">
 7		<cfset loc.args.property = "birthday">
 8		<cfset loc.args.includeblank = false>
 9		<cfset loc.args.order = "year">
10		<cfset loc.args.label = false>
11		<cfset loc.controller.changeBirthday = changeBirthday>
12	</cffunction>
13
14	<cffunction name="test_startyear_lt_endyear_value_lt_startyear">
15		<cfset loc.args.startyear = "1980">
16		<cfset loc.args.endyear = "1990">
17		<cfset loc.r = loc.controller.dateSelect(argumentCollection=loc.args)>
18		<cfset debug('loc.r', false)>
19		<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><option value="1981">1981</option><option value="1982">1982</option><option value="1983">1983</option><option value="1984">1984</option><option value="1985">1985</option><option value="1986">1986</option><option value="1987">1987</option><option value="1988">1988</option><option value="1989">1989</option><option value="1990">1990</option></select>'>
20		<cfset assert('loc.e eq loc.r')>
21	</cffunction>
22
23	<cffunction name="test_startyear_lt_endyear_value_gt_startyear">
24		<cfset loc.controller.changeBirthday("1995")>
25		<cfset loc.args.startyear = "1980">
26		<cfset loc.args.endyear = "1990">
27		<cfset loc.r = loc.controller.dateSelect(argumentCollection=loc.args)>
28		<cfset debug('loc.r', false)>
29		<cfset loc.e = '<select id="user-birthday-year" name="user[birthday]($year)"><option value="1980">1980</option><option value="1981">1981</option><option value="1982">1982</option><option value="1983">1983</option><option value="1984">1984</option><option value="1985">1985</option><option value="1986">1986</option><option value="1987">1987</option><option value="1988">1988</option><option value="1989">1989</option><option value="1990">1990</option></select>'>
30		<cfset assert('loc.e eq loc.r')>
31	</cffunction>
32
33	<cffunction name="test_startyear_gt_endyear_value_lt_endyear">
34		<cfset loc.args.startyear = "1990">
35		<cfset loc.args.endyear = "1980">
36		<cfset loc.r = loc.controller.dateSelect(argumentCollection=loc.args)>
37		<cfset debug('loc.r', false)>
38		<cfset loc.e = '<select id="user-birthday-year" name="user[birthday]($year)"><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option selected="selected" value="1975">1975</option></select>'>
39		<cfset assert('loc.e eq loc.r')>
40	</cffunction>
41
42	<cffunction name="test_startyear_gt_endyear_value_gt_endyear">
43		<cfset loc.controller.changeBirthday("1995")>
44		<cfset loc.args.startyear = "1990">
45		<cfset loc.args.endyear = "1980">
46		<cfset loc.r = loc.controller.dateSelect(argumentCollection=loc.args)>
47		<cfset debug('loc.r', false)>
48		<cfset loc.e = '<select id="user-birthday-year" name="user[birthday]($year)"><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option></select>'>
49		<cfset assert('loc.e eq loc.r')>
50	</cffunction>
51
52	<cffunction name="changeBirthday">
53		<cfargument name="value" type="any" required="true">
54		<cfset user.birthday = arguments.value>
55	</cffunction>
56
57</cfcomponent>