root/coldbox/trunk/ApplicationTemplate/test/integration/mxunit/mainTest.cfc @ 2103

Revision 2103, 3.5 kB (checked in by lmajano, 4 years ago)

First run of refactorings

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