| [ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
base include file for SimpleTest
| Version: | $Id: mock_objects.php,v 1.86 2005/09/10 23:01:56 lastcraft Exp $ |
| File Size: | 519 lines (19 kb) |
| Included or required: | 1 time |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
MockFunction:: (19 methods):
MockFunction()
restore()
_instance()
_generateSubClass()
setWildcard()
getCallCount()
setReturnValue()
setReturnValueAt()
setReturnReference()
setReturnReferenceAt()
expectArguments()
expectArgumentsAt()
expectCallCount()
expectMaximumCallCount()
expectMinimumCallCount()
expectNever()
expectOnce()
expectAtLeastOnce()
atTestEnd()
SimpleMockFunction:: (3 methods):
SimpleMockFunction()
deploy()
restore()
SimpleFunctionGenerator:: (2 methods):
SimpleFunctionGenerator()
_generateMockFunction()
SimpleDeclaredFunctionGenerator:: (4 methods):
SimpleDeclaredFunctionGenerator()
_generateTmpFnFname()
deploy()
restore()
SimpleUndeclaredFunctionGenerator:: (2 methods):
deploy()
restore()
Class: MockFunction - X-Ref
Generates a mock version of a function.| MockFunction() X-Ref |
| Raises an error if you construct MockFunction |
| restore($function) X-Ref |
| No description |
| _instance($function, $fresh = FALSE) X-Ref |
| Fetch a singleton instance of SimpleMockFunction param: string $function Function name param: boolean $fresh Force a fresh instance |
| _generateSubClass($class, $method) X-Ref |
| Required for strict mode and SimpleMock param: string $class subclass name param: string $method method name |
| setWildcard($function, $wildcard) X-Ref |
| Changes the default wildcard object. param: string $function Function name wildcard applies to param: mixed $wildcard Parameter matching wildcard. |
| getCallCount($function) X-Ref |
| Fetches the call count of a function so far. param: string $function Function name called. return: Number of calls so far. |
| setReturnValue($function, $value, $args = false) X-Ref |
| Sets a return for a parameter list that will be passed by value for all calls to this function. param: string $function Function name. param: mixed $value Result of call passed by value. param: array $args List of parameters to match |
| setReturnValueAt($timing, $function, $value, $args = false) X-Ref |
| Sets a return for a parameter list that will be passed by value only when the required call count is reached. param: integer $timing Number of calls in the future param: string $function Function name. param: mixed $value Result of call passed by value. param: array $args List of parameters to match |
| setReturnReference($function, &$reference, $args = false) X-Ref |
| Sets a return for a parameter list that will be passed by reference for all calls. param: string $function Function name. param: mixed $reference Result of the call will be this object. param: array $args List of parameters to match |
| setReturnReferenceAt($timing, $function, &$reference, $args = false) X-Ref |
| Sets a return for a parameter list that will be passed by value only when the required call count is reached. param: integer $timing Number of calls in the future param: string $function Function name. param: mixed $reference Result of the call will be this object. param: array $args List of parameters to match |
| expectArguments($function, $args, $message = '%s') X-Ref |
| 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. param: string $function Function call to test. param: array $args Expected parameters for the call param: string $message Overridden message. |
| expectArgumentsAt($timing, $function, $args, $message = '%s') X-Ref |
| 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. param: integer $timing Number of calls in the future at param: string $function Function call to test. param: array $args Expected parameters for the call param: string $message Overridden message. |
| expectCallCount($function, $count, $message = '%s') X-Ref |
| Sets an expectation for the number of times a function will be called. param: string $function Function call to test. param: integer $count Number of times it should param: string $message Overridden message. |
| expectMaximumCallCount($function, $count, $message = '%s') X-Ref |
| Sets the number of times a function may be called before a test failure is triggered. param: string $function Function call to test. param: integer $count Most number of times it should param: string $message Overridden message. |
| expectMinimumCallCount($function, $count, $message = '%s') X-Ref |
| Sets the minimum number of times the function must be called otherwise a test failure is triggered param: string $function Function call to test. param: integer $count Least number of times it should param: string $message Overridden message. |
| expectNever($function, $message = '%s') X-Ref |
| Convenience method for barring a function call. param: string $function Function call to ban. param: string $message Overridden message. |
| expectOnce($function, $args = false, $message = '%s') X-Ref |
| Convenience method for a single function call. param: string $function Function call to track. param: array $args Expected argument list or param: string $message Overridden message. |
| expectAtLeastOnce($function, $args = false, $message = '%s') X-Ref |
| Convenience method for requiring a function call. param: string $function Function call to track. param: array $args Expected argument list or param: string $message Overridden message. |
| atTestEnd($function) X-Ref |
| No description |
Class: SimpleMockFunction - X-Ref
Represents a single, mocked function, tracking calls made to it| SimpleMockFunction($function) X-Ref |
| Sets up the mock, creating a generator depending on whether the function is already declared param: string $function Name of function being mocked |
| deploy() X-Ref |
| Deploys the mock function implementation into PHP's function table, replacing any existing implementation |
| restore() X-Ref |
| Restores the state of PHP's function table to that before the mock function was deployed. Removes the mock function implementation and restores any existing implementation of that function |
Class: SimpleFunctionGenerator - X-Ref
Base class for deploying and restoring from mock functions| SimpleFunctionGenerator($function) X-Ref |
param: string $function Name of function being mocked |
| _generateMockFunction() X-Ref |
| Generates the mock function implementation, using eval |
Class: SimpleDeclaredFunctionGenerator - X-Ref
Mock function generator for functions which have already been declared| SimpleDeclaredFunctionGenerator($function) X-Ref |
| Invokes the _generateTmpFnFname param: string $function Name of function being mocked |
| _generateTmpFnFname() X-Ref |
| Generates a temporary name for the declared function implementation which is will be renamed to while the mock function is in use |
| deploy() X-Ref |
| Deploys the mock function implementation |
| restore() X-Ref |
| Removes the mock function implementation and restores the previously declared implementation |
| Generated: Wed Dec 3 01:30:02 2008 | Cross-referenced by PHPXref 0.7 |