Skip to content

Commit 807d973

Browse files
committed
- New start:fakemail command to start FakeSMTP for testing
- Addded fake smtp server for testing on the harness
1 parent 0f4d9a1 commit 807d973

File tree

6 files changed

+47
-27
lines changed

6 files changed

+47
-27
lines changed

box.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"format":"cfformat run handlers/,interceptors/,models/,test-harness/tests/specs,ModuleConfig.cfc --overwrite",
4343
"format:watch":"cfformat watch handlers/,interceptors/,models/,test-harness/tests/specs,ModuleConfig.cfc ./.cfformat.json",
4444
"format:check":"cfformat check handlers/,interceptors/,models/,test-harness/tests/specs,ModuleConfig.cfc ./.cfformat.json",
45+
"start:fakemail": "!docker compose -f test-harness/tests/resources/docker-compose.yml up --detach",
4546
"start:lucee" : "server start [email protected]",
4647
"start:2018" : "server start [email protected]",
4748
"start:2021" : "server start [email protected]",

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Github Support Files
1515
- Github Action Updates
1616
- ColdBox 7 Auto Testing
17+
- New `start:fakemail` command to start FakeSMTP for testing
18+
- Addded fake smtp server for testing on the harness
1719

1820
## [v2.7.1] => 2023-FEB-14
1921

[email protected]

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
"rewrites":{
1212
"enable":"true"
1313
},
14-
"webroot": "test-harness",
14+
"webroot":"test-harness",
1515
"aliases":{
1616
"/moduleroot/cbmailservices":"../"
1717
}
1818
},
1919
"openBrowser":"false",
20-
"cfconfig": {
21-
"file" : ".cfconfig.json"
22-
}
20+
"cfconfig":{
21+
"file":".cfconfig.json"
22+
}
2323
}

test-harness/Application.cfc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ component{
4747
this.mappings[ "/moduleroot" ] = moduleRootPath;
4848
this.mappings[ "/#request.MODULE_NAME#" ] = modulePath;
4949

50-
this.datasource = "cbmailservices";
50+
// Define the fake smtp server
51+
this.mail = {
52+
server = "localhost",
53+
port = 25,
54+
};
5155

5256
// application start
5357
public boolean function onApplicationStart(){
@@ -77,4 +81,4 @@ component{
7781
return application.cbBootstrap.onMissingTemplate( argumentCollection=arguments );
7882
}
7983

80-
}
84+
}

test-harness/tests/Application.cfc

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,66 @@
11
/**
2-
********************************************************************************
3-
Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4-
www.ortussolutions.com
5-
********************************************************************************
2+
* ********************************************************************************
3+
* Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4+
* www.ortussolutions.com
5+
* ********************************************************************************
66
*/
77
component {
88

9+
// UPDATE THE NAME OF THE MODULE IN TESTING BELOW
10+
request.MODULE_NAME = "cbmailservices";
11+
request.MODULE_PATH = "cbmailservices";
12+
913
// APPLICATION CFC PROPERTIES
10-
this.name = "ColdBoxTestingSuite" & hash( getCurrentTemplatePath() );
14+
this.name = "#request.MODULE_NAME# Testing Suite";
1115
this.sessionManagement = true;
1216
this.sessionTimeout = createTimespan( 0, 0, 15, 0 );
1317
this.applicationTimeout = createTimespan( 0, 0, 15, 0 );
1418
this.setClientCookies = true;
1519

16-
this.smtpServerSettings = {
17-
server : "localhost"
18-
};
19-
2020
// Create testing mapping
2121
this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() );
2222

2323
// The application root
2424
rootPath = reReplaceNoCase( this.mappings[ "/tests" ], "tests(\\|/)", "" );
2525
this.mappings[ "/root" ] = rootPath;
2626

27-
// UPDATE THE NAME OF THE MODULE IN TESTING BELOW
28-
request.MODULE_NAME = "cbmailservices";
29-
3027
// The module root path
3128
moduleRootPath = reReplaceNoCase( this.mappings[ "/root" ], "#request.module_name#(\\|/)test-harness(\\|/)", "" );
3229
this.mappings[ "/moduleroot" ] = moduleRootPath;
3330
this.mappings[ "/#request.MODULE_NAME#" ] = moduleRootPath & "#request.MODULE_NAME#";
3431

35-
this.datasource = "cbmailservices";
32+
// Define the fake smtp server
33+
this.mail = {
34+
server = "localhost",
35+
port = 25,
36+
};
3637

3738
// request start
3839
public boolean function onRequestStart( String targetPage ){
40+
41+
// Set a high timeout for long running tests
42+
setting requestTimeout="9999";
43+
// New ColdBox Virtual Application Starter
44+
request.coldBoxVirtualApp = new coldbox.system.testing.VirtualApp( appMapping = "/root" );
45+
46+
// ORM Reload for fresh results
47+
if( structKeyExists( url, "fwreinit" ) ){
48+
if( structKeyExists( server, "lucee" ) ){
49+
pagePoolClear();
50+
}
51+
request.coldBoxVirtualApp.shutdown();
52+
}
53+
54+
// If hitting the runner or specs, prep our virtual app
55+
if ( getBaseTemplatePath().replace( expandPath( "/tests" ), "" ).reFindNoCase( "(runner|specs)" ) ) {
56+
request.coldBoxVirtualApp.startup();
57+
}
58+
3959
return true;
4060
}
4161

4262
public function onRequestEnd(){
43-
// CB 6 graceful shutdown
44-
if ( !isNull( application.cbController ) ) {
45-
application.cbController.getLoaderService().processShutdown();
46-
}
47-
48-
structDelete( application, "cbController" );
49-
structDelete( application, "wirebox" );
63+
request.coldBoxVirtualApp.shutdown();
5064
}
5165

5266
}

test-harness/tests/specs/MailServiceTest.cfc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* executes before all suites+specs in the run() method
77
*/
88
function beforeAll(){
9-
structDelete( application, "cbController" );
109
super.beforeAll();
1110
super.setup();
1211
}

0 commit comments

Comments
 (0)