/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. <cfinclude template="setupAndTeardown.cfm">
  3. <cfset params = {controller="test", action="test"}>
  4. <cfset loc.controller = controller("test", params)>
  5. <cffunction name="test_rendering_without_layout">
  6. <cfset loc.controller.renderPage(layout=false)>
  7. <cfset assert("loc.controller.response() IS 'view template content'")>
  8. </cffunction>
  9. <cffunction name="test_rendering_with_default_layout_in_controller_folder">
  10. <cfset tempFile = expandPath("/wheelsMapping/tests/_assets/views/test/layout.cfm")>
  11. <cffile action="write" output="<cfoutput>start:controllerlayout##includeContent()##end:controllerlayout</cfoutput>" file="#tempFile#">
  12. <cfset application.wheels.existingLayoutFiles = "test">
  13. <cfset loc.controller.renderPage()>
  14. <cfset loc.r = loc.controller.response()>
  15. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:controllerlayout' AND loc.r Contains 'end:controllerlayout'")>
  16. <cfset application.wheels.existingLayoutFiles = "">
  17. <cffile action="delete" file="#tempFile#">
  18. </cffunction>
  19. <cffunction name="test_rendering_with_default_layout_in_root">
  20. <cfset loc.controller.renderPage()>
  21. <cfset loc.r = loc.controller.response()>
  22. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:defaultlayout' AND loc.r Contains 'end:defaultlayout'")>
  23. </cffunction>
  24. <cffunction name="test_rendering_with_specific_layout">
  25. <cfset loc.controller.renderPage(layout="specificLayout")>
  26. <cfset loc.r = loc.controller.response()>
  27. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:specificlayout' AND loc.r Contains 'end:specificlayout'")>
  28. </cffunction>
  29. <cffunction name="test_removing_cfm_file_extension_when_supplied">
  30. <cfset loc.controller.renderPage(layout="specificLayout.cfm")>
  31. <cfset loc.r = loc.controller.response()>
  32. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:specificlayout' AND loc.r Contains 'end:specificlayout'")>
  33. </cffunction>
  34. <cffunction name="test_rendering_with_specific_layout_in_root">
  35. <cfset loc.controller.renderPage(layout="/rootLayout")>
  36. <cfset loc.r = loc.controller.response()>
  37. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:rootlayout' AND loc.r Contains 'end:rootlayout'")>
  38. </cffunction>
  39. <cffunction name="test_rendering_with_specific_layout_in_sub_folder">
  40. <cfset loc.controller.renderPage(layout="sub/layout")>
  41. <cfset loc.r = loc.controller.response()>
  42. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:sublayout' AND loc.r Contains 'end:sublayout'")>
  43. </cffunction>
  44. <cffunction name="test_rendering_with_specific_layout_from_folder_path">
  45. <cfset loc.controller.renderPage(layout="/shared/layout")>
  46. <cfset loc.r = loc.controller.response()>
  47. <cfset assert("loc.r Contains 'view template content' AND loc.r Contains 'start:sharedlayout' AND loc.r Contains 'end:sharedlayout'")>
  48. </cffunction>
  49. <cffunction name="test_view_variable_should_be_available_in_layout_file">
  50. <cfset loc.controller.$callAction(action="test")>
  51. <cfset loc.controller.renderPage()>
  52. <cfset loc.r = loc.controller.response()>
  53. <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'")>
  54. </cffunction>
  55. <cffunction name="test_rendering_partial_with_layout">
  56. <cfset loc.controller.renderPartial(partial="partialTemplate", layout="partialLayout")>
  57. <cfset loc.r = loc.controller.response()>
  58. <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'")>
  59. </cffunction>
  60. <cffunction name="test_rendering_partial_with_specific_layout_in_root">
  61. <cfset loc.controller.renderPartial(partial="partialTemplate", layout="/partialRootLayout")>
  62. <cfset loc.r = loc.controller.response()>
  63. <cfset assert("loc.r Contains 'partial template content' AND loc.r Contains 'start:partialrootlayout' AND loc.r Contains 'end:partialrootlayout'")>
  64. </cffunction>
  65. </cfcomponent>