Метод | Описание | |
---|---|---|
__construct ( ) | Creates an empty action list and expectation list. | |
atTestEnd ( string $test_method, SimpleTestCase &$test ) | Receives event from unit test that the current test method has finished. | |
disableExpectationNameChecks ( ) | Disables a name check when setting expectations. | |
errorAt ( integer $timing, string $method, object $error = 'A mock error', array $args = false, integer $severity = E_USER_ERROR ) | Sets up a trigger to throw an error upon a specific method call. | |
errorOn ( string $method, object $error = 'A mock error', array $args = false, integer $severity = E_USER_ERROR ) | Sets up a trigger to throw an error upon the method call. | |
expect ( string $method, array $args, string $message = '%s' ) | Sets up an expected call with a set of expected parameters in that call. | |
expectAt ( integer $timing, string $method, array $args, string $message = '%s' ) | Sets up an expected call with a set of expected parameters in that call. | |
expectAtLeastOnce ( string $method, array $args = false, string $message = '%s' ) | Convenience method for requiring a method call. | |
expectCallCount ( string $method, integer $count, string $message = '%s' ) | Sets an expectation for the number of times a method will be called. | |
expectMaximumCallCount ( string $method, integer $count, string $message = '%s' ) | Sets the number of times a method may be called before a test failure is triggered. | |
expectMinimumCallCount ( string $method, integer $count, string $message = '%s' ) | Sets the number of times to call a method to prevent a failure on the tally. | |
expectNever ( string $method, string $message = '%s' ) | Convenience method for barring a method call. | |
expectOnce ( string $method, array $args = false, string $message = '%s' ) | Convenience method for a single method call. | |
getCallCount ( string $method ) : integer | Fetches the call count of a method so far. | |
invoke ( string $method, array $args ) : mixed | Returns the expected value for the method name and checks expectations. | |
replaceWildcards ( array $args ) : array | Replaces wildcard matches with wildcard expectations in the argument list. | |
returns ( string $method, mixed $value, array $args = false ) | Sets a return for a parameter list that will be passed on by all calls to this method that match. | |
returnsAt ( integer $timing, string $method, mixed $value, array $args = false ) | Sets a return for a parameter list that will be passed only when the required call count is reached. | |
returnsByReference ( string $method, mixed &$reference, array $args = false ) | Sets a return for a parameter list that will be passed by reference for all calls. | |
returnsByReferenceAt ( integer $timing, string $method, mixed &$reference, array $args = false ) | Sets a return for a parameter list that will be passed by value only when the required call count is reached. | |
returnsByValue ( string $method, mixed $value, array $args = false ) | Sets a return for a parameter list that will be passed by value for all calls to this method. | |
returnsByValueAt ( integer $timing, string $method, mixed $value, array $args = false ) | Sets a return for a parameter list that will be passed by value only when the required call count is reached. | |
throwAt ( integer $timing, string $method, object $exception = false, array $args = false ) | Sets up a trigger to throw an exception upon the method call. | |
throwOn ( string $method, object $exception = false, array $args = false ) | Sets up a trigger to throw an exception upon the method call. |
Метод | Описание | |
---|---|---|
addCall ( string $method, array $args ) | Adds one to the call count of a method. | |
checkArgumentsIsArray ( mixed $args, string $task ) : boolean | Die if bad arguments array is passed. | |
checkExpectations ( string $method, array $args, integer $timing ) | Tests the arguments against expectations. | |
dieOnNoMethod ( string $method, string $task ) | Triggers a PHP error if the method is not part of this object. | |
emulateCall ( string $method, array $args, integer $step ) : mixed | Finds the return value matching the incoming arguments. | |
getCurrentTestCase ( ) : SimpeTestCase | Finds currently running test. |
Метод | Описание | |
---|---|---|
disableEStrict ( ) | Our mock has to be able to return anything, including variable references. | |
restoreEStrict ( integer $was ) | Restores the E_STRICT level if it was previously set. |
protected dieOnNoMethod ( string $method, string $task ) | ||
$method | string | Name of method. |
$task | string | Description of task attempt. |
public disableExpectationNameChecks ( ) |
public errorAt ( integer $timing, string $method, object $error = 'A mock error', array $args = false, integer $severity = E_USER_ERROR ) | ||
$timing | integer | When to throw the exception. A value of 0 throws immediately. A value of 1 actually allows one call to this method before throwing. 2 will allow two calls before throwing and so on. |
$method | string | Method name to throw on. |
$error | object | Error message to trigger. |
$args | array | Optional argument list filter. If given then the exception will only be thrown if the method call matches the arguments. |
$severity | integer | The PHP severity level. Defaults to E_USER_ERROR. |
public errorOn ( string $method, object $error = 'A mock error', array $args = false, integer $severity = E_USER_ERROR ) | ||
$method | string | Method name to throw on. |
$error | object | Error message to trigger. |
$args | array | Optional argument list filter. If given then the exception will only be thrown if the method call matches the arguments. |
$severity | integer | The PHP severity level. Defaults to E_USER_ERROR. |
public expectAt ( integer $timing, string $method, array $args, string $message = '%s' ) | ||
$timing | integer | Number of calls in the future at which to test. Next call is 0. |
$method | string | Method call to test. |
$args | array | Expected parameters for the call including wildcards. |
$message | string | Overridden message. |
public expectNever ( string $method, string $message = '%s' ) | ||
$method | string | Method call to ban. |
$message | string | Overridden message. |
public getCallCount ( string $method ) : integer | ||
$method | string | Method name called. |
Результат | integer | Number of calls so far. |
protected getCurrentTestCase ( ) : SimpeTestCase | ||
Результат | SimpeTestCase | Current test case. |
public replaceWildcards ( array $args ) : array | ||
$args | array | Raw argument list. |
Результат | array | Argument list with expectations. |
public returnsAt ( integer $timing, string $method, mixed $value, array $args = false ) | ||
$timing | integer | Number of calls in the future to which the result applies. If not set then all calls will return the value. |
$method | string | Method name. |
$value | mixed | Result of call passed. |
$args | array | List of parameters to match including wildcards. |
public returnsByReferenceAt ( integer $timing, string $method, mixed &$reference, array $args = false ) | ||
$timing | integer | Number of calls in the future to which the result applies. If not set then all calls will return the value. |
$method | string | Method name. |
$reference | mixed | Result of the call will be this object. |
$args | array | List of parameters to match including wildcards. |
public returnsByValueAt ( integer $timing, string $method, mixed $value, array $args = false ) | ||
$timing | integer | Number of calls in the future to which the result applies. If not set then all calls will return the value. |
$method | string | Method name. |
$value | mixed | Result of call passed by value. |
$args | array | List of parameters to match including wildcards. |
public throwAt ( integer $timing, string $method, object $exception = false, array $args = false ) | ||
$timing | integer | When to throw the exception. A value of 0 throws immediately. A value of 1 actually allows one call to this method before throwing. 2 will allow two calls before throwing and so on. |
$method | string | Method name to throw on. |
$exception | object | Exception object to throw. If not given then a simple Exception object is thrown. |
$args | array | Optional argument list filter. If given then the exception will only be thrown if the method call matches the arguments. |
public throwOn ( string $method, object $exception = false, array $args = false ) | ||
$method | string | Method name to throw on. |
$exception | object | Exception object to throw. If not given then a simple Exception object is thrown. |
$args | array | Optional argument list filter. If given then the exception will only be thrown if the method call matches the arguments. |