Creates an empty action list and expectation list.
All call counts are set to zero.
SimpleMock
SimpleMock
()
Receives event from unit test that the current test method has finished. Totals up the call counts and triggers a test assertion if a test is present for expected call counts.
-
string
$test_method: Current method name.
-
SimpleTestCase
$test: Test to send message to.
-
&$test
Disables a name check when setting expectations.
This hack is needed for the partial mocks.
void
disableExpectationNameChecks
()
Sets up a trigger to throw an error upon the method call.
void
errorAt
( $timing, $method, [ $error = 'A mock error'], [ $args = false], [ $severity = E_USER_ERROR])
-
$timing
-
$method
-
$error
-
$args
-
$severity
Sets up a trigger to throw an error upon the method call.
void
errorOn
( $method, [ $error = 'A mock error'], [ $args = false], [ $severity = E_USER_ERROR])
-
$method
-
$error
-
$args
-
$severity
Sets up an expected call with a set of expected parameters in that call. All calls will be compared to these expectations regardless of when the call is made.
void
expect
(string $method, array $args, [string $message = '%s'])
-
string
$method: Method call to test.
-
array
$args: Expected parameters for the call including wildcards.
-
string
$message: Overridden message.
void
expectArguments
( $method, $args, [ $message = '%s'])
void
expectArgumentsAt
( $timing, $method, $args, [ $message = '%s'])
-
$timing
-
$method
-
$args
-
$message
Sets up an expected call with a set of expected parameters in that call. The expected call count will be adjusted if it is set too low to reach this call.
void
expectAt
(integer $timing, string $method, array $args, [string $message = '%s'])
-
integer
$timing: Number of calls in the future at which to test. Next call is 0.
-
string
$method: Method call to test.
-
array
$args: Expected parameters for the call including wildcards.
-
string
$message: Overridden message.
Convenience method for requiring a method call.
void
expectAtLeastOnce
(string $method, [array $args = false], [string $message = '%s'])
-
string
$method: Method call to track.
-
array
$args: Expected argument list or false for any arguments.
-
string
$message: Overridden message.
Sets an expectation for the number of times a method will be called. The tally method is used to check this.
void
expectCallCount
(string $method, integer $count, [string $message = '%s'])
-
string
$method: Method call to test.
-
integer
$count: Number of times it should have been called at tally.
-
string
$message: Overridden message.
Sets the number of times a method may be called before a test failure is triggered.
void
expectMaximumCallCount
(string $method, integer $count, [string $message = '%s'])
-
string
$method: Method call to test.
-
integer
$count: Most number of times it should have been called.
-
string
$message: Overridden message.
Sets the number of times to call a method to prevent a failure on the tally.
void
expectMinimumCallCount
(string $method, integer $count, [string $message = '%s'])
-
string
$method: Method call to test.
-
integer
$count: Least number of times it should have been called.
-
string
$message: Overridden message.
Convenience method for barring a method call.
void
expectNever
(string $method, [string $message = '%s'])
-
string
$method: Method call to ban.
-
string
$message: Overridden message.
Convenience method for a single method call.
void
expectOnce
(string $method, [array $args = false], [string $message = '%s'])
-
string
$method: Method call to track.
-
array
$args: Expected argument list or false for any arguments.
-
string
$message: Overridden message.
Fetches the call count of a method so far.
integer
getCallCount
(string $method)
-
string
$method: Method name called.
Sets a return for a parameter list that will be passed by reference for all calls.
void
setReturnReference
(string $method, &$reference, [array $args = false], mixed $reference)
-
string
$method: Method name.
-
mixed
$reference: Result of the call will be this object.
-
array
$args: List of parameters to match including wildcards.
-
&$reference
Sets a return for a parameter list that will be passed by value only when the required call count is reached.
void
setReturnReferenceAt
(integer $timing, string $method, &$reference, [array $args = false], mixed $reference)
-
integer
$timing: Number of calls in the future to which the result applies. If not set then all calls will return the value.
-
string
$method: Method name.
-
mixed
$reference: Result of the call will be this object.
-
array
$args: List of parameters to match including wildcards.
-
&$reference
Sets a return for a parameter list that will be passed by value for all calls to this method.
void
setReturnValue
(string $method, mixed $value, [array $args = false])
-
string
$method: Method name.
-
mixed
$value: Result of call passed by value.
-
array
$args: List of parameters to match including wildcards.
Sets a return for a parameter list that will be passed by value only when the required call count is reached.
void
setReturnValueAt
(integer $timing, string $method, mixed $value, [array $args = false])
-
integer
$timing: Number of calls in the future to which the result applies. If not set then all calls will return the value.
-
string
$method: Method name.
-
mixed
$value: Result of call passed by value.
-
array
$args: List of parameters to match including wildcards.
Sets up a trigger to throw an exception upon the method call.
void
throwAt
( $timing, $method, [ $exception = false], [ $args = false])
-
$timing
-
$method
-
$exception
-
$args
Sets up a trigger to throw an exception upon the method call.
void
throwOn
(string $method, [ $exception = false], [ $args = false])
-
string
$method: Method name to throw on.
-
$exception
-
$args
Adds one to the call count of a method.
void
_addCall
(string $method, array $args)
-
string
$method: Method called.
-
array
$args: Arguments as an array.
Triggers a PHP error if the method is not part of this object.
void
_dieOnNoMethod
(string $method, string $task)
-
string
$method: Name of method.
-
string
$task: Description of task attempt.
Finds the return value matching the incoming arguments. If there is no matching value found then an error is triggered.
mixed
&_emulateCall
(string $method, array $args, integer $step)
-
string
$method: Method name.
-
array
$args: Calling arguments.
-
integer
$step: Current position in the call history.
Finds currently running test.
SimpeTestCase
&_getCurrentTestCase
()