Class Mock

Description

Static methods only service class for code generation of mock objects.

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


	
			
Method Summary
 Mock Mock ()
 void generate (string $class, [string $mock_class = false], [array $methods = false])
 void generatePartial (string $class, string $mock_class, array $methods)
 string getExpectationLine ([string $format = '%d'], [array $stack = false])
 string _addMethodList (array $methods)
 string _bailOutIfNotMocked (string $alias)
 string _chainMockReturns ()
 string _createClassCode (string $class, string $mock_class, array $methods)
 string _extendClassCode (string $class, string $mock_class, array $methods)
 string _overrideMethods (array $methods)
Methods
Constructor Mock (line 1016)

Factory for mock object classes.

  • access: public
Mock Mock ()
generate (line 1035)

Clones a class' interface and creates a mock version that can have return values and expectations set.

  • access: public
  • static:
void generate (string $class, [string $mock_class = false], [array $methods = false])
  • string $class: Class to clone.
  • string $mock_class: New class name. Default is the old name with "Mock" prepended.
  • array $methods: Additional methods to add beyond those in th cloned class. Use this to emulate the dynamic addition of methods in the cloned class or when the class hasn't been written yet.
generatePartial (line 1063)

Generates a version of a class with selected methods mocked only. Inherits the old class and chains the mock methods of an aggregated mock object.

  • access: public
  • static:
void generatePartial (string $class, string $mock_class, array $methods)
  • string $class: Class to clone.
  • string $mock_class: New class name.
  • array $methods: Methods to be overridden with mock versions.
getExpectationLine (line 1248)

Uses a stack trace to find the line of an assertion.

  • return: Line number of first assert* method embedded in format string.
  • static:
  • access: public
string getExpectationLine ([string $format = '%d'], [array $stack = false])
  • string $format: String formatting.
  • array $stack: Stack frames top most first. Only needed if not using the PHP backtrace function.
_addMethodList (line 1128)

Creates a list of mocked methods for error checking.

  • return: Code for a method list.
  • access: private
string _addMethodList (array $methods)
  • array $methods: Mocked methods.
_bailOutIfNotMocked (line 1139)

Creates code to abandon the expectation if not mocked.

  • return: Code for bail out.
  • access: private
string _bailOutIfNotMocked (string $alias)
  • string $alias: Parameter name of method name.
_chainMockExpectations (line 1179)

Creates source code for chaining to an aggregated mock object.

  • return: Code for expectations.
  • access: private
string _chainMockExpectations ()
_chainMockReturns (line 1153)

Creates source code for chaining to the composited mock object.

  • return: Code for mock set up.
  • access: private
string _chainMockReturns ()
_createClassCode (line 1083)

The new mock class code as a string.

  • return: Code for new mock class.
  • access: private
  • static:
string _createClassCode (string $class, string $mock_class, array $methods)
  • string $class: Class to clone.
  • string $mock_class: New class name.
  • array $methods: Additional methods.
_extendClassCode (line 1105)

The extension class code as a string. The class composites a mock object and chains mocked methods to it.

  • return: Code for a new class.
  • access: private
  • static:
string _extendClassCode (string $class, string $mock_class, array $methods)
  • string $class: Class to extend.
  • string $mock_class: New class name.
  • array $methods: Mocked methods.
_overrideMethods (line 1226)

Creates source code to override a list of methods with mock versions.

  • return: Code for overridden chains.
  • access: private
string _overrideMethods (array $methods)
  • array $methods: Methods to be overridden with mock versions.

Documentation generated on Fri, 11 Feb 2005 18:13:33 +0000 by phpDocumentor 1.3.0RC3