|
ColdBox Platform Version 3.7.0 | ||||
FRAMES |
WEB-INF.cftags.componentcoldbox.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 |
$(string method, [any returns], boolean preserveReturnType='true', [boolean throwException='false'], [string throwType=''], [string throwDetail=''], [string throwMessage=''], [boolean callLogging='false'])
Mock a Method, simple but magical Injected as: $() |
any |
$args()
Use this method to mock specific arguments when calling a mocked method |
boolean |
$atLeast(numeric minNumberOfInvocations, [string methodName=''])
Assert that at least a certain number of calls have been made on the mock or a specific mock method |
boolean |
$atMost(numeric maxNumberOfInvocations, [string methodName=''])
Assert that at most a certain number of calls have been made on the mock or a specific mock method |
struct |
$callLog()
Retrieve the method call logger structures |
numeric |
$count([string methodName=''])
I return the number of times the specified mock object's methods have been called or a specific method has been called |
struct |
$debug()
Debugging method for MockBox enabled mocks/stubs, useful to find out things about your mocks |
any |
$getProperty(any name, [any scope='variables'], [any default])
Gets an internal mocked object property |
boolean |
$never([string methodName=''])
Assert that no interactions have been made to the mock or a specific mock method: Alias to $times(0) |
boolean |
$once([string methodName=''])
Assert that only 1 call has been made on the mock or a specific mock method |
any |
$property(string propertyName, [string propertyScope='variables'], any mock)
Mock a property inside of an object in any scope |
any |
$reset()
Reset all mock counters and logs on the targeted mock |
any |
$results()
Use this method to mock more than 1 result as passed in arguments |
boolean |
$times(numeric count, [string methodName=''])
Assert how many calls have been made to the mock or a specific mock method: Injected as $verifyCallCount() and $times() |
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'], [string extends=''], [string implements=''])
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()
Get the Mock Generator Utility |
private Util |
getUtil()
Create and return a util object |
string |
getVersion()
Get the MockBox version |
any |
maildump([any content='failure'], [any to='safeldkamp@natsem.com'], [any subject='MockBox.cfc'])
|
any |
normalizeArguments(any args)
Normalize argument values on method calls |
any |
prepareMock([any object], [boolean callLogging='true'])
Prepares an already instantiated object to act as a mock for spying and much more |
query |
querySim(string queryData)
First line are the query columns separated by commas |
void |
setGenerationPath(string generationPath)
Override the mocks 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 $(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 any $args()
public boolean $atLeast(numeric minNumberOfInvocations, [string methodName=''])
minNumberOfInvocations
- The min number of calls to assertmethodName
- Name of the method to verify the calls from, if blank, from the entire mockpublic boolean $atMost(numeric maxNumberOfInvocations, [string methodName=''])
maxNumberOfInvocations
- The max number of calls to assertmethodName
- Name of the method to verify the calls from, if blank, from the entire mockpublic struct $callLog()
public numeric $count([string methodName=''])
methodName
- Name of the method to get the total made calls from. If not passed, then we count all methods in this mock objectpublic struct $debug()
public any $getProperty(any name, [any scope='variables'], [any default])
name
- The name of the property to retrieve.scope
- The scope to which to retrieve the property from. Defaults to 'variables' scope.default
- Default value to return if property does not existpublic boolean $never([string methodName=''])
methodName
- Name of the method to verify the calls frompublic boolean $once([string methodName=''])
methodName
- Name of the method to verify the calls from, if blank, from the entire mockpublic any $property(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 $reset()
public any $results()
public boolean $times(numeric count, [string methodName=''])
count
- The number of calls to assertmethodName
- Name of the method to verify the calls from, if not passed it asserts all mocked method callspublic 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'], [string extends=''], [string implements=''])
callLogging
- Add method call logging for all mocked methodsextends
- Make the stub extend from certain CFCimplements
- Make the stub adhere to an interfaceprivate void decorateMock(any target)
target
- The target objectpublic string getGenerationPath()
public MockGenerator getMockGenerator()
private Util getUtil()
public string getVersion()
public any maildump([any content='failure'], [any to='safeldkamp@natsem.com'], [any subject='MockBox.cfc'])
content
to
subject
public any normalizeArguments(any args)
args
- The arguments structure to normalizepublic 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 3.7.0 | ||||
FRAMES |