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

/wheels/tests/controller/rendering/layouts.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 79 lines | 65 code | 14 blank | 0 comment | 0 complexity | d51429925c8ed4b857e1398745bf9ed5 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cfinclude template="setupAndTeardown.cfm">
 4
 5	<cfset params = {controller="test", action="test"}>
 6	<cfset loc.controller = controller("test", params)>
 7
 8	<cffunction name="test_rendering_without_layout">
 9		<cfset loc.controller.renderPage(layout=false)>
10		<cfset assert("loc.controller.response() IS 'view template content'")>
11	</cffunction>
12
13	<cffunction name="test_rendering_with_default_layout_in_controller_folder">
14		<cfset tempFile = expandPath("/wheelsMapping/tests/_assets/views/test/layout.cfm")>
15		<cffile action="write" output="<cfoutput>start:controllerlayout##includeContent()##end:controllerlayout</cfoutput>" file="#tempFile#">
16		<cfset application.wheels.existingLayoutFiles = "test">
17		<cfset loc.controller.renderPage()>
18		<cfset loc.r = loc.controller.response()>
19		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:controllerlayout' AND loc.r Contains 'end:controllerlayout'")>
20		<cfset application.wheels.existingLayoutFiles = "">
21		<cffile action="delete" file="#tempFile#">
22	</cffunction>
23
24	<cffunction name="test_rendering_with_default_layout_in_root">
25		<cfset loc.controller.renderPage()>
26		<cfset loc.r = loc.controller.response()>
27		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:defaultlayout' AND loc.r Contains 'end:defaultlayout'")>
28	</cffunction>
29
30	<cffunction name="test_rendering_with_specific_layout">
31		<cfset loc.controller.renderPage(layout="specificLayout")>
32		<cfset loc.r = loc.controller.response()>
33		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:specificlayout' AND loc.r Contains 'end:specificlayout'")>
34	</cffunction>
35
36	<cffunction name="test_removing_cfm_file_extension_when_supplied">
37		<cfset loc.controller.renderPage(layout="specificLayout.cfm")>
38		<cfset loc.r = loc.controller.response()>
39		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:specificlayout' AND loc.r Contains 'end:specificlayout'")>
40	</cffunction>
41
42	<cffunction name="test_rendering_with_specific_layout_in_root">
43		<cfset loc.controller.renderPage(layout="/rootLayout")>
44		<cfset loc.r = loc.controller.response()>
45		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:rootlayout' AND loc.r Contains 'end:rootlayout'")>
46	</cffunction>
47
48	<cffunction name="test_rendering_with_specific_layout_in_sub_folder">
49		<cfset loc.controller.renderPage(layout="sub/layout")>
50		<cfset loc.r = loc.controller.response()>
51		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:sublayout' AND loc.r Contains 'end:sublayout'")>
52	</cffunction>
53
54	<cffunction name="test_rendering_with_specific_layout_from_folder_path">
55		<cfset loc.controller.renderPage(layout="/shared/layout")>
56		<cfset loc.r = loc.controller.response()>
57		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:sharedlayout' AND loc.r Contains 'end:sharedlayout'")>
58	</cffunction>
59
60	<cffunction name="test_view_variable_should_be_available_in_layout_file">
61		<cfset loc.controller.$callAction(action="test")>
62		<cfset loc.controller.renderPage()>
63		<cfset loc.r = loc.controller.response()>
64		<cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'variableForLayoutContent' AND loc.r Contains 'start:defaultlayout' AND loc.r Contains 'end:defaultlayout'")>
65	</cffunction>
66
67	<cffunction name="test_rendering_partial_with_layout">
68		<cfset loc.controller.renderPartial(partial="partialTemplate", layout="partialLayout")>
69		<cfset loc.r = loc.controller.response()>
70		<cfset assert("loc.r Does Not Contain 'view template content' AND loc.r Contains 'partial template content' AND loc.r Contains 'start:partiallayout' AND loc.r Contains 'end:partiallayout'")>
71	</cffunction>
72
73	<cffunction name="test_rendering_partial_with_specific_layout_in_root">
74		<cfset loc.controller.renderPartial(partial="partialTemplate", layout="/partialRootLayout")>
75		<cfset loc.r = loc.controller.response()>
76		<cfset assert("loc.r Contains 'partial template content' AND loc.r Contains 'start:partialrootlayout' AND loc.r Contains 'end:partialrootlayout'")>
77	</cffunction>
78
79</cfcomponent>