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

/wheels/tests/view/forms/startFormTag.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 81 lines | 71 code | 10 blank | 0 comment | 0 complexity | 7c5ced3b2773b95e0b514468f1a0c830 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.controller = controller(name="dummy")>
 5		<cfset loc.args= {}>
 6		<cfset loc.args.host = "">
 7		<cfset loc.args.method = "post">
 8		<cfset loc.args.multipart = false>
 9		<cfset loc.args.onlypath = true>
10		<cfset loc.args.port = 0>
11		<cfset loc.args.protocol = "">
12		<cfset loc.args.spamprotection = false>
13		<cfset loc.args.controller = "testcontroller">
14	</cffunction>
15
16	<cffunction name="test_no_controller_or_action_or_route_should_point_to_current_page">
17		<cfset structdelete(loc.args, "controller")>
18		<cfset loc.argsction = loc.controller.urlfor(argumentCollection=loc.args)>
19		<cfset loc.e = '<form action="#loc.argsction#" method="post">'>
20		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
21		<cfset assert('loc.e eq loc.r')>
22	</cffunction>
23
24	<cffunction name="test_with_controller">
25		<cfset loc.argsction = loc.controller.urlfor(argumentCollection=loc.args)>
26		<cfset loc.e = '<form action="#loc.argsction#" method="post">'>
27		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
28		<cfset assert("loc.e eq loc.r", "testing this out")>
29	</cffunction>
30
31	<cffunction name="test_with_get_method">
32		<cfset loc.args.method = "get">
33		<cfset loc.argsction = loc.controller.urlfor(argumentCollection=loc.args)>
34		<cfset loc.e = '<form action="#loc.argsction#" method="get">'>
35		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
36		<cfset assert("loc.e eq loc.r")>
37	</cffunction>
38
39	<cffunction name="test_with_multipart">
40		<cfset loc.args.multipart = "true">
41		<cfset loc.argsction = loc.controller.urlfor(argumentCollection=loc.args)>
42		<cfset loc.e = loc.controller.startFormTag(argumentcollection=loc.args)>
43		<cfset loc.r = '<form action="#loc.argsction#" enctype="multipart/form-data" method="post">'>
44		<cfset assert("loc.e eq loc.r")>
45	</cffunction>
46
47	<cffunction name="test_with_spamProtection">
48		<cfset loc.args.spamProtection = "true">
49		<cfset loc.args.action = "myaction">
50		<cfset loc.argsction = loc.controller.toXHTML(loc.controller.urlfor(argumentCollection=loc.args))>
51		<cfset loc.e = '<form data-this-action="#Left(loc.argsction, int((Len(loc.argsction)/2)))##Right(loc.argsction, ceiling((Len(loc.argsction)/2)))#" method="post">'>
52		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
53		<cfset assert("loc.e eq loc.r")>
54	</cffunction>
55
56	<cffunction name="test_with_home_route">
57		<cfset loc.args.route = "home">
58		<cfset loc.argsction = loc.controller.toXHTML(loc.controller.urlfor(argumentCollection=loc.args))>
59		<cfset loc.e = '<form action="#loc.argsction#" method="post">'>
60		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
61		<cfset assert("loc.e eq loc.r")>
62	</cffunction>
63
64	<cffunction name="test_external_link">
65		<cfset loc.args.action = "https://www.cfwheels.com">
66		<cfset loc.args.multipart = true>
67		<cfset loc.e = '<form action="https://www.cfwheels.com" enctype="multipart/form-data" method="post">'>
68		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
69		<cfset assert("loc.e eq loc.r")>
70	</cffunction>
71	
72	<cffunction name="test_remote_link">
73		<cfset loc.args.route = "home">
74		<cfset loc.args.remote = "true">
75		<cfset loc.action = loc.controller.toXHTML(loc.controller.urlfor(argumentCollection=loc.args))>
76		<cfset loc.e = '<form action="#loc.action#" data-remote="true" method="post">'>
77		<cfset loc.r = loc.controller.startFormTag(argumentcollection=loc.args)>
78		<cfset assert("loc.e eq loc.r")>
79	</cffunction>
80
81</cfcomponent>