Mockbox - Mocking internal CF methods?

Hello Guys,

I’ve got a couple of methods within a CFC which are very heavily reliant on internal CF methods, such as getDirectoryFromPath() and expandPath()

Is it possible for me to overwrite these with mock methods so I can control and test for varying responses?

Thanks,

Robert

Yes, but you would need to refactor the code to call a method to encase/wrap these functions.

I see, so I would need to have myExpandPath() method which in turn calls the native cf method? I can then mock my custom one?

Thanks, Rob.

Or better yet would be to break the calls to the paths down into specific functions then mock the results

Let’s say you were uploading a file and wanted the path to your uploads directory, then I would have a small utility method like below and then you can mock that.

function getFileUploadPath() {

return expandPath(‘/uploads’);

}

Rather than just a blanket function to duplicate the expandPath.

Curt Gratz

I see - this makes sense. Thanks guys I’ll work off of this premis.