[Testbox] How to test handlers in nested modules (e.g. contentbox)

We have an application that includes contentbox as a module, and within /modules/contentbox/modules/ we have other modules.

In Testbox, if I do:

var event = execute(‘module:handler.function’);

It works for a handler inside a normal module, but for a module inside the contentbox module it errors with:

The event: module:handler.function is not valid registered event.

I tried also with /module/handler/function (i.e. how it is requested) but that gives same error.

What do I need to do to make this work?

You have to verify that the module is loaded and activated within ContentBox first.


Luis F. Majano
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

Social: twitter.com/lmajano facebook.com/lmajano

Luis wrote:

You have to verify that the module is loaded and activated within ContentBox first.

Ah, it’s obvious now you’ve said it!

We do have conditional module activation going on, since not everything will be available for all sites.

I’ve solved that immediate problem with:

var ModuleService = getController().getModuleService();

if ( NOT StructKeyExists( ModuleService.getModuleRegistry() , ‘ModuleName’ ) )
ModuleService.registerAndActivateModule( ‘ModuleName’ , ‘contentbox.modules’ );

So now it can find the event and the execute call works, though it is getting tripped up by a ContentBox redirect:


Which I’m pretty certain is because the database I’m running the tests against doesn’t yet have the relevant tables/data setup for ContentBox, so I’ll have to fix that.