- Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathBaseIntegrationTest.cfc
92 lines (76 loc) · 2.46 KB
/
BaseIntegrationTest.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*******************************************************************************
* Integration Test as BDD
*
* Extends the integration class: coldbox.system.testing.BaseTestCase
*
* so you can test your ColdBox application headlessly. The 'appMapping' points by default to
* the '/root' mapping created in the test folder Application.cfc. Please note that this
* Application.cfc must mimic the real one in your root, including ORM settings if needed.
*
* The 'execute()' method is used to execute a ColdBox event, with the following arguments
* * event : the name of the event
* * private : if the event is private or not
* * prePostExempt : if the event needs to be exempt of pre post interceptors
* * eventArguments : The struct of args to pass to the event
* * renderResults : Render back the results of the event
*******************************************************************************/
component
extends="coldbox.system.testing.BaseTestCase"
appMapping="/cbTestHarness"
{
// Load on first test
this.loadColdBox=true;
// Never unload until the request dies
this.unloadColdBox=false;
/*********************************** LIFE CYCLE Methods ***********************************/
functionbeforeAll(){
// Cleanup
cleanupColdBoxRequestData();
structDelete( url, "event" );
structDelete( url, "format" );
// Super size me!
super.beforeAll();
// add custom matchers
addMatchers( {
toHavePartialKey:function( expectation, args= {} ){
// iterate over actual to find key
for ( varthisKeyinarguments.expectation.actual ) {
if ( findNoCase( arguments.args[ 1 ], thisKey ) ) {
returntrue;
}
}
returnfalse;
}
} );
}
functionafterAll(){
// do your own stuff here
super.afterAll();
}
/**
* Cleanup for invalid handler on all tests
* @beforeEach
*/
functioncleanupColdBoxRequestData(){
structDelete( request, "_lastInvalidEvent" );
structDelete( request, "cbTransientDICache" )
}
functionisAdobe(){
returnserver.keyExists( "coldfusion" ) &&server.coldfusion.productName.findNoCase( "ColdFusion" );
}
functionisLucee(){
returnserver.keyExists( "lucee" );
}
functionisBoxLang(){
returnserver.keyExists( "boxlang" );
}
functionisLucee6(){
returnserver.keyExists( "lucee" ) &&left( server.lucee.version, 1 ) ==6;
}
functionnoWSDLSupport(){
returnisAdobe() || isLucee6() || isBoxLang();
}
functionshutdownColdBox(){
getColdBoxVirtualApp().shutdown();
}
}