Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The following methods are also mixed in at run-time into mock objects and they will be used to verify behavior and calls from these mock/stub objects. These are great in order to find out how many mocked methods calls have been made and to find out the arguments that where passed to each mocked method call.
Method Name
Return Type
Description
$count([methodName])
Numeric
Get the number of times all mocked methods have been called on a mock or pass in a method name and get a the method's call count.
$times(count,[methodName]) or $verifyCallCount(count,[methodName])
Numeric
Assert how many calls have been made to the mock or a specific mock method
$never([methodName])
Boolean
Assert that no interactions have been made to the mock or a specific mock method: Alias to $times(0)
$atLeast(minNumberOfInvocations,[methodName])
Boolean
Assert that at least a certain number of calls have been made on the mock or a specific mock method
$once([methodName])
Boolean
Assert that only 1 call has been made on the mock or a specific mock method
$atMost(maxNumberOfInvocations, [methodName])
Boolean
Assert that at most a certain number of calls have been made on the mock or a specific mock method.
$callLog()
struct
Retrieve the method call logger structure of all mocked method calls.
$reset()
void
Reset all mock counters and logs on the targeted mock.
$debug()
struct
Retrieve a structure of mocking debugging information about a mock object.
This method is used to assert how many times a mocked method has been called or ANY mocked method has been called.
Parameters:
count - The number of times any method or a specific mocked method has been called
methodName - The optional method name to assert the number of method calls
Examples
This method can help you verify that at least a minimum number of calls have been made to all mocked methods or a specific mocked method.
Parameters:
minNumberOfInvocations - The min number of calls to assert
methodName - The optional method name to assert the number of method calls
This method is used to retrieve a structure of method calls that have been made on mocked methods of the mock object. This is extermely useful when you want to assert that a certain method was called with the appropriate arguments. Great for testing method calls that save or update data to some kind of persistent storage. Also great to find out what was the state of the data of a call at certain points in time.
Each mocked method is a key in the structure that contains an array of calls. Each array element can have 0 or more arguments that are traced when methods where called with arguments. If they where made with ordered or named arguments, you will be able to know the difference. We recommend dumping out the structure to check out its composition.
Examples:
This method can help you verify that only ONE mocked method call has been made on the entire mock or a specific mocked method. Useful alias!
Parameters:
methodName - The optional method name to assert the number of method calls
Examples:
This method is used for debugging purposes. If you would like to get a structure of all the mocking internals of an object, just call this method and it will return to you a structure of data that you can dump for debugging purposes.
Get the number of times a method has been called or the entire number of calls made to ANY mocked method on this mock object. If the method has never been called, you will receive a 0. If the method does not exist or has not been mocked, then it will return a -1.
Parameters:
methodName - Name of the method to get the counter for (Optional)
This method is a quick notation for the $times(0)
call but more expressive when written in code:
Parameters:
* methodName - The optional method name to assert the number of method calls
Examples:
This method can help you verify that at most a maximum number of calls have been made to all mocked methods or a specific mocked method.
Parameters:
maxNumberOfInvocations - The max number of calls to assert
methodName - The optional method name to assert the number of method calls
Examples:
This method is a utility method used to clear out all call logging and method counters.