|
ColdBox Platform Version 2.6.4 | ||||
| FRAMES | |||||
WEB-INF.cftags.component
coldbox.system.testing.MockBox
public class MockBox
A unit testing mocking/stubing factory for ColdFusion 7 and above and any CFML Engine
| Constructor Summary | |
|---|---|
init([string generationPath=''])
Create an instance of MockBox |
|
| Method Summary | |
|---|---|
any |
createEmptyMock([string className], [any object], [boolean callLogging='true'])
Creates an empty mock object |
any |
createMock([string className], [any object], [boolean clearMethods='false'], [boolean callLogging='true'])
Create a mock object or prepares an object to act as a mock for spying |
any |
createStub([boolean callLogging='true'])
Create an empty stub object that you can use for mocking |
private void |
decorateMock(any target)
Decorate a mock object |
string |
getGenerationPath()
Get the current generation path |
MockGenerator |
getMockGenerator()
|
private Util |
getUtil()
Create and return a util object |
string |
getVersion()
Get the current mock factory version |
any |
mockArgs()
Use this method to mock specific arguments when calling a mocked method |
struct |
mockCallLog()
Retrieve the method call logger structure |
private struct |
mockDebug()
Debugging method for MockBox |
any |
mockMethod(string method, [any returns], boolean preserveReturnType='true', [boolean throwException='false'], [string throwType=''], [string throwDetail=''], [string throwMessage=''], [boolean callLogging='false'])
Mock a Method, very simply, no fancy stuff |
numeric |
mockMethodCallCount([string methodName=''])
I return the number of times the specified mock method has been called or ALL mock methods have been called |
any |
mockProperty(string propertyName, [string propertyScope='variables'], any mock)
Mock a property inside of an object in any scope |
any |
mockResults()
Use this method to mock more than 1 result as passed in arguments |
boolean |
mockVerifyCallCount(numeric count, [string methodName=''])
Assert how many calls have been made to the mock or a specific mock method |
any |
prepareMock([any object], [boolean callLogging='true'])
Prepares an object to act as a mock for spying |
query |
querySim(string queryData)
First line are the query columns separated by commas |
void |
setGenerationPath(string generationPath)
Override the generation path |
| Methods inherited from class WEB-INF.cftags.component |
|---|
|
| Constructor Detail |
|---|
public init([string generationPath=''])
generationPath - The mocking generation relative path. If not defined, then the factory will use its internal tmp path. Just make sure that this folder is accessible from an include.| Method Detail |
|---|
public any createEmptyMock([string className], [any object], [boolean callLogging='true'])
className - The class name of the object to mock. The mock factory will instantiate it for youobject - The object to mock, already instantiatedcallLogging - Add method call logging for all mocked methods. Defaults to truepublic any createMock([string className], [any object], [boolean clearMethods='false'], [boolean callLogging='true'])
className - The class name of the object to mock. The mock factory will instantiate it for youobject - The object to mock, already instantiatedclearMethods - If true, all methods in the target mock object will be removed. You can then mock only the methods that you want to mock. Defaults to falsecallLogging - Add method call logging for all mocked methods. Defaults to truepublic any createStub([boolean callLogging='true'])
callLogging - Add method call logging for all mocked methodsprivate void decorateMock(any target)
target - The target objectpublic string getGenerationPath()
public MockGenerator getMockGenerator()
private Util getUtil()
public string getVersion()
public any mockArgs()
public struct mockCallLog()
private struct mockDebug()
public any mockMethod(string method, [any returns], boolean preserveReturnType='true', [boolean throwException='false'], [string throwType=''], [string throwDetail=''], [string throwMessage=''], [boolean callLogging='false'])
method - The method you want to mock or spy onreturns - The results it must return, if not passed it returns void or you will have to do the mockResults() chainpreserveReturnType - If false, the mock will make the returntype of the method equal to ANYthrowException - If you want the method call to throw an exceptionthrowType - The type of the exception to throwthrowDetail - The detail of the exception to throwthrowMessage - The message of the exception to throwcallLogging - Will add the machinery to also log the incoming arguments to each subsequent calls to this methodpublic numeric mockMethodCallCount([string methodName=''])
methodName - Name of the method to get calls frompublic any mockProperty(string propertyName, [string propertyScope='variables'], any mock)
propertyName - The name of the property to mockpropertyScope - The scope where the property lives in. By default we will use the variables scope.mock - The object or data to injectpublic any mockResults()
public boolean mockVerifyCallCount(numeric count, [string methodName=''])
count - The number of calls mademethodName - Name of the method to verify the calls frompublic any prepareMock([any object], [boolean callLogging='true'])
object - The already instantiated object to prepare for mockingcallLogging - Add method call logging for all mocked methodspublic query querySim(string queryData)
queryData - The data to create queriespublic void setGenerationPath(string generationPath)
generationPath
|
ColdBox Platform Version 2.6.4 | ||||
| FRAMES | |||||