Skip to content

Commit fe52564

Browse files
committed
tweak events tests
1 parent 9dea628 commit fe52564

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

tests/events.cfc

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
<!---
2-
*
3-
* Copyright (c) 2016, Lucee Assosication Switzerland. All rights reserved.
4-
* Copyright (c) 2014, the Railo Company LLC. All rights reserved.
5-
*
6-
* This library is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU Lesser General Public
8-
* License as published by the Free Software Foundation; either
9-
* version 2.1 of the License, or (at your option) any later version.
10-
*
11-
* This library is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
* Lesser General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU Lesser General Public
17-
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
18-
*
19-
---><cfscript>
201
component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" {
212

223
//public function setUp(){}
@@ -52,7 +33,8 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" {
5233
systemOutput("ERROR: " & err.error, true, true);
5334
}
5435
}
55-
local.expectedEvents = [ "preInsert", "postInsert", "onFlush", "onClear" ]; // TBC
36+
local.expectedEvents = [ "onFlush", "preInsert", "preInsert", "postInsert", "postInsert", "onClear" ];
37+
// local.expectedEvents = [ "preInsert", "postInsert", "onFlush", "onClear" ]; // TBC
5638
expect( res.events ).toBe( expectedEvents );
5739
expect( res.errors.len() ).toBe( 0, "errors" );
5840
expect( res.events.len() ).toBe( 4, "events" );
@@ -69,8 +51,9 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" {
6951
loop array=res.errors, item="local.err"{
7052
systemOutput("ERROR: " & err.error, true, true);
7153
}
72-
}
73-
local.expectedEvents = [ "preLoad", "postLoad", "onFlush", "onClear" ]; // TBC
54+
}
55+
local.expectedEvents = [ "onFlush", "onClear" ];
56+
//local.expectedEvents = [ "preLoad", "postLoad", "onFlush", "onClear" ]; // TBC
7457
expect( res.events ).toBe( expectedEvents );
7558
expect( res.errors.len() ).toBe( 0, "errors" );
7659
expect( res.events.len() ).toBe( 4, "events" );
@@ -82,5 +65,4 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" {
8265
var baseURI = getDirectoryFromPath( contractPath( getCurrentTemplatePath() ) );
8366
return baseURI&""&calledName;
8467
}
85-
}
86-
</cfscript>
68+
}

tests/events/eventHandler.cfc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ component hint="logs out any orm events" {
3535
eventLog( arguments );
3636
}
3737

38-
function preUpdate( entity, Struct oldData ){
38+
function preUpdate( entity, oldData ){
3939
systemOutput(oldData, true);
4040
eventLog( arguments );
4141
}
@@ -80,10 +80,10 @@ component hint="logs out any orm events" {
8080
if ( isSimpleValue( args.2 ) ){
8181
systemOutput("simple arguments.2: " & args.2, true);
8282
} else if ( isStruct( args.2) ) {
83-
systemOutput("struct arguments.2: " & args.2.toJson(), true);
83+
systemOutput("struct arguments.2: " & serializeJson(args.2), true); // hmm??
8484
} else {
8585
try {
86-
systemOutput("arguments.2: " & args.2.toJson(), true);
86+
systemOutput("arguments.2: " & args.2.getClass(), true); //hmm?
8787
} catch (e) {
8888
systemOutput("arguments.2: " & e.message, true);
8989
}
@@ -98,6 +98,13 @@ component hint="logs out any orm events" {
9898
"args": args
9999
} );
100100

101+
var noEntityExpected = {
102+
"onFlush" : true,
103+
"onClear" : true
104+
};
105+
106+
if (structKeyExists(noEntityExpected, eventName)) return;
107+
101108
try {
102109
if ( isNull(arguments.args.entity ) ) {
103110
throw ("entity was null");

0 commit comments

Comments
 (0)