/SampleApplication/ColdBox3/test/integration/mainTest.cfc

http://github.com/bobsilverberg/ValidateThisColdBoxPlugin · ColdFusion CFScript · 121 lines · 59 code · 35 blank · 27 comment · 1 complexity · 3eb9a178640cc27990b3541522ff6670 MD5 · raw file

  1. <!-----------------------------------------------------------------------
  2. Author : Luis Majano
  3. Date : September 25, 2005
  4. Description :
  5. Unit test for the ehMain Handler.
  6. ----------------------------------------------------------------------->
  7. <cfcomponent name="mainTest" extends="coldbox.system.testing.BaseTestCase" output="false">
  8. <cfscript>
  9. //Uncomment the following if you dont' need the controller in application scope for testing.
  10. //this.PERSIST_FRAMEWORK = false;
  11. </cfscript>
  12. <cffunction name="setup" returntype="void" output="false">
  13. <cfscript>
  14. //Setup ColdBox Mappings For this Test
  15. setAppMapping("/coldbox/ApplicationTemplate");
  16. setConfigMapping(ExpandPath(instance.AppMapping & "/config/coldbox.xml.cfm"));
  17. //Call the super setup method to setup the app.
  18. super.setup();
  19. //EXECUTE THE APPLICATION START HANDLER: UNCOMMENT IF NEEDED AND FILL IT OUT WITH THE CORRECT HANDLER
  20. //getController().runEvent("main.onAppInit");
  21. //EXECUTE THE ON REQUEST START HANDLER: UNCOMMENT IF NEEDED AND FILL IT OUT WITH THE CORRECT HANDLER
  22. //getController().runEvent("main.onRequestStart");
  23. </cfscript>
  24. </cffunction>
  25. <cffunction name="testonAppInit" returntype="void" output="false">
  26. <cfscript>
  27. var event = "";
  28. //Place any variables on the form or URL scope to test the handler.
  29. //FORM.name = "luis"
  30. event = execute("main.onAppInit");
  31. //Do your asserts below
  32. </cfscript>
  33. </cffunction>
  34. <cffunction name="testonRequestStart" returntype="void" output="false">
  35. <cfscript>
  36. var event = "";
  37. //Place any variables on the form or URL scope to test the handler.
  38. //FORM.name = "luis"
  39. event = execute("main.onRequestStart");
  40. //Do your asserts below
  41. </cfscript>
  42. </cffunction>
  43. <cffunction name="testonRequestEnd" returntype="void" output="false">
  44. <cfscript>
  45. var event = "";
  46. //Place any variables on the form or URL scope to test the handler.
  47. //FORM.name = "luis"
  48. event = execute("main.onRequestEnd");
  49. //Do your asserts below
  50. </cfscript>
  51. </cffunction>
  52. <cffunction name="testSessionStart" returntype="void" output="false">
  53. <cfscript>
  54. var event = "";
  55. //Place any variables on the form or URL scope to test the handler.
  56. //FORM.name = "luis"
  57. event = execute("main.onSessionStart");
  58. //Do your asserts below
  59. </cfscript>
  60. </cffunction>
  61. <cffunction name="testSessionEnd" returntype="void" output="false">
  62. <cfscript>
  63. var event = "";
  64. var sessionReference = "";
  65. //Place a fake session structure here, it mimics what the handler receives
  66. URL.sessionReference = structnew();
  67. URL.applicationReference = structnew();
  68. event = execute("main.onSessionEnd");
  69. //Do your asserts below
  70. </cfscript>
  71. </cffunction>
  72. <cffunction name="testonException" returntype="void" output="false">
  73. <cfscript>
  74. //You need to create an exception bean first and place it on the request context FIRST as a setup.
  75. var exceptionBean = CreateObject("component","coldbox.system.beans.ExceptionBean");
  76. var event = "";
  77. //Initialize an exception
  78. exceptionBean.init(erroStruct=structnew(), extramessage="My unit test exception", extraInfo="Any extra info, simple or complex");
  79. //Place it on form or url scope to attach it to request
  80. URL.exceptionBean = exceptionBean;
  81. //TEST EVENT EXECUTION
  82. event = execute("main.onException");
  83. //Do your asserts HERE
  84. </cfscript>
  85. </cffunction>
  86. </cfcomponent>