[testbox 1.0.0] MXUnit's Mock() - how to use MockBox to replace

I’ve got some tests which use MXUnit’s Mock() and am trying to figure out how I can replace the same code using TestBox/MockBox

I’m forking the Xindi CMS project - you can see the tests here: https://github.com/simonbingham/xindi/blob/master/_tests/model/content/TestContentService.cfc

function testgetNavigationByPage(){
var Page = mock().getleftvalue().returns(1).getrightvalue().returns(20);
var pages = CUT.getNavigation( page=Page );
assertTrue( isQuery( pages ) );

Is there a drop in way to replicate that with MockBox?

I’ve never done a lot with mocking before… off to RTFM for MockBox… :slight_smile:


Something like this should get you on track:

var Page = mockbox.createMock(“path.to.page”).$(“getleftvalue”,1).$(“getrightvalue”,20);



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Awesome - thank for the quick reply Brad!

I think I was close - was missing the $. Will try again in the AM!


Woot! Just needed to add a $ to mockbox as well:

var Page = $mockbox.createMock(“path.to.page”).$(“getleftvalue”,1).$(“getrightvalue”,20);