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(); = 1;
myStruct.two = 2;
myStruct.three = 3;

myCustomDAOMock.$("getKey").$args(argumentCollection = myStruct).

and call it like this:

myStruct = structNew(); = 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:


Take a look at this straight coldfusion code for an interesting

  stuArgs = structNew(); = 1;
  stuArgs.four = '';
  stuArgs.two = '"London*"';
  stuArgs.three = '';
  stuArgs.six = '';
<cfdump var="#stuArgs#">

<br />

  stuNewParams = structNew();
  stuNewParams.four = ''; = 1;
  stuNewParams.three = '';
  stuNewParams.six = '';
  stuNewParams.two = '"London*"';
<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
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager: