Class SimpleStub

Description

An empty collection of methods that can have their return values set. Used for prototyping.

Located in /libraries/pear/simpletest/mock_objects.php (line 286)


	
			
Direct descendents
Class Description
 class SpecialSimpleStub An empty collection of methods that can have their return values set. Used for prototyping.
 class SimpleMock An empty collection of methods that can have their
Variable Summary
Method Summary
 SimpleStub SimpleStub (mixed $wildcard, [boolean$is_strict $is_strict = true])
 void clearHistory ()
 Number getCallCount (string $method)
 void setReturnReference (string $method, mixed &$reference, [array $args = false])
 void setReturnReferenceAt (integer $timing, string $method, mixed &$reference, [array $args = false])
 void setReturnValue (string $method, mixed $value, [array $args = false])
 void setReturnValueAt (integer $timing, string $method, mixed $value, [array $args = false])
 void _addCall (string $method, array $args)
 void _dieOnNoMethod (string $method, string $task)
 mixed &_getReturn (string $method, array $args, integer $step)
 mixed &_invoke (string $method, array $args)
 array _replaceWildcards (array $args)
 void _warnOnNoReturn (string $method)
Variables
mixed $_call_counts (line 291)
mixed $_is_strict (line 288)
mixed $_returns (line 289)
mixed $_return_sequence (line 290)
mixed $_wildcard (line 287)
Methods
Constructor SimpleStub (line 299)

Sets up the wildcard and everything else empty.

  • access: public
SimpleStub SimpleStub (mixed $wildcard, [boolean$is_strict $is_strict = true])
  • mixed $wildcard: Parameter matching wildcard.
  • boolean$is_strict $is_strict: Enables method name checks.
clearHistory (line 330)
  • deprecated:
void clearHistory ()
getCallCount (line 382)

Fetches the call count of a method so far.

  • return: of calls so far.
  • access: public
Number getCallCount (string $method)
  • string $method: Method name called.
setReturnReference (line 446)

Sets a return for a parameter list that will be passed by reference for all calls.

  • access: public
void setReturnReference (string $method, mixed &$reference, [array $args = false])
  • string $method: Method name.
  • mixed $reference: Result of the call will be this object.
  • array $args: List of parameters to match including wildcards.
setReturnReferenceAt (line 470)

Sets a return for a parameter list that will be passed by value only when the required call count is reached.

  • access: public
void setReturnReferenceAt (integer $timing, string $method, mixed &$reference, [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 $reference: Result of the call will be this object.
  • array $args: List of parameters to match including wildcards.
setReturnValue (line 400)

Sets a return for a parameter list that will be passed by value for all calls to this method.

  • access: public
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.
setReturnValueAt (line 424)

Sets a return for a parameter list that will be passed by value only when the required call count is reached.

  • access: public
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.
_addCall (line 369)

Adds one to the call count of a method.

  • access: protected
void _addCall (string $method, array $args)
  • string $method: Method called.
  • array $args: Arguments as an array.
_dieOnNoMethod (line 355)

Triggers a PHP error if the method is not part of this object.

  • access: protected
void _dieOnNoMethod (string $method, string $task)
  • string $method: Name of method.
  • string $task: Description of task attempt.
_getReturn (line 494)

Finds the return value matching the incoming arguments. If there is no matching value found then an error is triggered.

  • return: Stored return.
  • access: protected
mixed &_getReturn (string $method, array $args, integer $step)
  • string $method: Method name.
  • array $args: Calling arguments.
  • integer $step: Current position in the call history.
_invoke (line 341)

Returns the expected value for the method name.

  • return: Stored return.
  • access: private
mixed &_invoke (string $method, array $args)
  • string $method: Name of method to simulate.
  • array $args: Arguments as an array.

Redefined in descendants as:
  • SimpleMock::_invoke() : Returns the expected value for the method name and checks expectations. Will generate any test assertions as a result of expectations if there is a test present.
_replaceWildcards (line 315)

Replaces wildcard matches with wildcard expectations in the argument list.

  • return: Argument list with expectations.
  • access: private
array _replaceWildcards (array $args)
  • array $args: Raw argument list.
_warnOnNoReturn (line 513)

What to do if there is no return value set. Does nothing for a stub.

  • access: protected
void _warnOnNoReturn (string $method)
  • string $method: Method name.

Redefined in descendants as:

Documentation generated on Thu, 20 Jan 2005 17:10:17 +0000 by phpDocumentor 1.3.0RC3