Strange behavior in structure handling with mocbox

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#">

Same issue as the other entry in the list. Positional paramters are used when mocking and named paramters for execution. These will not match. Choose one.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com