Some of our services have caches injected using Wirebox.
When trying to run the test harness, this errors with the message “The DSL Definition … did not produce any resulting dependency”
The DSL Definition {JAVACAST={null},NAME={cache},ARGNAME={},DSL={cachebox:clientDB},VALUE={null},REQUIRED={true},SCOPE={variables},REF={null}} did not produce any resulting dependency
I can’t find any examples of how to mock a cache - I tried adding the following to beforeAll in the base testcase:
Variables.Cachebox = getController().getCacheBox();
if ( NOT ArrayFind(Cachebox.getCacheNames(),‘clientDB’) )
{
var cache = new coldbox.system.cache.providers.MockProvider();
cache.setName(‘clientDB’);
Cachebox.addCache(cache);
}
That doesn’t do anything - same error.
How do I fix it?
I’ve worked around this by updating a couple of core files:
/coldbox/system/ioc/dsl/CacheBoxDSL.cfc after line 46:
else if (true)
{
return new coldbox.system.cache.providers.MockProvider();
}
Meaning the MockProvider is returned for any unknown DSL.
That mostly worked, but I then had to wrap StructKeyExists around the MockProvider.cfc get return, to receive nulls when the key doesn’t exist.
<cfif StructKeyExists(instance.cache,arguments.objectKey)>
<cfreturn instance.cache[ arguments.objectKey ]>
Not a solution, but at least it allows me to check the tests are passing.
Our Coldbox app has a cache injected via Wirebox:
property name=“cache” inject=“cachebox:clientDB”
This works fine in the application, but in Testbox it errors with the message:
The DSL Definition … did not produce any resulting dependency
What needs to be done with Mockbox to create a mock cache so the tests can run?