2

I was finally able to get mxunit and mocking working on my local Windows install but after the sys admin installed it on our Linux server I get the following error only when I use it. It works fine for another app that does not require mocking.

Offending code:

mockLogger = getMockBox().createMock('coldbox.system.logging.Logger');
mockLogger.$("info").$("debug").$("warn").$("error");
model.$property(propertyName="logger", mock=mockLogger);

Error:

/shared/coldbox/system/testing/stubs/9DA00BFE-CBB2-164D-DAB9269585B3E317.cfm (Permission denied)

Is there a something that I should be setting in my test/Application.cfc?

Aaron
  • 1,042
  • 2
  • 12
  • 30

1 Answers1

0

The error is because MXUnit / Mockbox is trying to create the file specified, but CF doesn't have permission to write to that location.

The usual fix for this would be to update the permissions for that stubs directory, so that CF can write and access the files there. (Use chown/chmod, or ask the sys admin to do it.)

The other option is to use a different location which CF does have permission to. You can set this by passing the generationPath argument to MockBox when you initialise it, either...

new coldbox.system.testing.MockBox( generationPath="path" )

... if you're initialising it yourself, or from a unit test...

getMockBox().init( generationPath="path" )

The path provided needs to be relative - i.e. something cfinclude can use, so it might be worth setting up a mapping.

Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
  • Thanks. I understand the issue but I wasn't sure about a end user solution such as controlling where the file could be created. Luis pointed me in the direction of getMockBox().init( generationPath="path" ). – Aaron Oct 11 '13 at 22:51
  • Doh, I was an idiot - dunno how I missed that it was on writing the file rather than reading, but anyhow I've updated the answer and mentioned that option too. – Peter Boughton Oct 12 '13 at 14:03
  • Also, if you haven't already, it's probably worth taking a read through the [Mockbox page](http://wiki.coldbox.org/wiki/MockBox.cfm) on the Coldbox wiki - plenty of information there. – Peter Boughton Oct 12 '13 at 14:04