I believe i have found a bug in mockbox and the way it handles
structures as arguments.
Structure sorting is handled automatically by coldfusion and is not
something developers normally have any control over. So i was quite
suprised when i noticed that when you load a structure in a different
order, the native mockbox method returns a different result.
I noticed this trying to pass an argument collection into a mock
method. If you set up a mock method like this:
myStruct = structNew();
myStruct.one = 1;
myStruct.two = 2;
myStruct.three = 3;
myCustomDAOMock.$("getKey").$args(argumentCollection = myStruct).
$results('devmail@mail.com');
and call it like this:
myStruct = structNew();
myStruct.one = 1;
myStruct.two = 2;
myStruct.three = 3;
stuResults = myCustomDAOMock.getKey(argumentCollection = stuParams);
If the arguments are NOT in the same order, this CAN cause a mismatch
and your results are not returned.
It is caused (i think) by this line in mockbox:
hash(arguments.toString())
Take a look at this straight coldfusion code for an interesting
example:
<cfscript>
stuArgs = structNew();
stuArgs.one = 1;
stuArgs.four = '';
stuArgs.two = '"London*"';
stuArgs.three = '';
stuArgs.six = '';
writeOutput(hash(stuArgs.toString()));
</cfscript>
<cfdump var="#stuArgs#">
<br />
<cfscript>
stuNewParams = structNew();
stuNewParams.four = '';
stuNewParams.one = 1;
stuNewParams.three = '';
stuNewParams.six = '';
stuNewParams.two = '"London*"';
writeOutput(hash(stuNewParams.toString()));
</cfscript>
<cfdump var="#stuNewParams#">