Hi,
Question on using spies with mockbox. Consider this:
/* Thing.cfc */
component{
function init(){
variables.counter = 0;
}
function doSomething(foo){
if (foo){
addit();
}
}
private function addit(){
variables.counter++;
}
}
What I want to do is test that the ‘addit’ method is called by the ‘doSomething’ method when arguments.foo is true. This is what I have in my test:
CUT = new model.Thing();
prepareMock(CUT);
CUT.doSomething(true);
assertEquals(1, CUT.$count(“addit”));
I can use the $getProperty method to do it, just wondered if you could use the $count method that’s injected.
…update…
you can do it by mocking the method, so I’ll do that, so this gives the desired result:
CUT = new model.Thing();
prepareMock(CUT);
CUT.$(“addit”);
CUT.doSomething(true);
assertEquals(1, CUT.$count(“addit”));