Class MockGenerator

Description

Service class for code generation of mock objects.

Located in /mock_objects.php (line 1248)


	
			
Method Summary
 MockGenerator __construct (string $class, string $mock_class)
 string addMethodList (array $methods)
 string bailOutIfNotMocked (string $alias)
 string chainMockReturns ()
 string chainThrowMethods ()
 string createClassCode (array $methods)
 void createHandlerCode (array $methods)
 void createNewMethodCode (array $methods)
 string createSubclassCode (array $methods)
 string extendClassCode (array $methods)
 void generate (array $methods)
 void generatePartial (array $methods)
 void generateSubclass (array $methods)
 boolean isConstructor (string $method)
 string overrideMethods (array $methods)
Methods
Constructor __construct (line 1260)

Builds initial reflection object.

MockGenerator __construct (string $class, string $mock_class)
  • string $class: Class to be mocked.
  • string $mock_class: New class with identical interface, but no behaviour.
addMethodList (line 1485)

Creates a list of mocked methods for error checking.

  • return: Code for a method list.
  • access: protected
string addMethodList (array $methods)
  • array $methods: Mocked methods.
bailOutIfNotMocked (line 1496)

Creates code to abandon the expectation if not mocked.

  • return: Code for bail out.
  • access: protected
string bailOutIfNotMocked (string $alias)
  • string $alias: Parameter name of method name.
chainMockExpectations (line 1559)

Creates source code for chaining to an aggregated mock object.

  • return: Code for expectations.
  • access: protected
string chainMockExpectations ()
chainMockReturns (line 1510)

Creates source code for chaining to the composited mock object.

  • return: Code for mock set up.
  • access: protected
string chainMockReturns ()
chainThrowMethods (line 1599)

Adds code for chaining the throw methods.

  • return: Code for chains.
  • access: protected
string chainThrowMethods ()
createClassCode (line 1344)

The new mock class code as a string.

  • return: Code for new mock class.
  • access: protected
string createClassCode (array $methods)
  • array $methods: Additional methods.
createHandlerCode (line 1422)

Creates code within a class to generate replaced methods. All methods call the invoke() handler with the method name and the arguments in an array.

  • access: protected
void createHandlerCode (array $methods)
  • array $methods: Additional methods.
createNewMethodCode (line 1449)

Creates code within a class to generate a new methods. All methods call the invoke() handler on the internal mock with the method name and the arguments in an array.

  • access: protected
void createNewMethodCode (array $methods)
  • array $methods: Additional methods.
createSubclassCode (line 1373)

The new mock class code as a string. The mock will be a subclass of the original mocked class.

  • return: Code for new mock class.
  • access: protected
string createSubclassCode (array $methods)
  • array $methods: Additional methods.
extendClassCode (line 1398)

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: protected
string extendClassCode (array $methods)
  • array $methods: Mocked methods.
generate (line 1279)

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

void generate (array $methods)
  • 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 1326)

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.

void generatePartial (array $methods)
  • array $methods: Methods to be overridden with mock versions.
generateSubclass (line 1301)

Subclasses a class and overrides every method with a mock one that can have return values and expectations set. Chains to an aggregated SimpleMock.

void generateSubclass (array $methods)
  • array $methods: Additional methods to add beyond those in the cloned class. Use this to emulate the dynamic addition of methods in the cloned class or when the class hasn't been written yet.
isConstructor (line 1474)

Tests to see if a special PHP method is about to be stubbed by mistake.

  • return: True if special.
  • access: protected
boolean isConstructor (string $method)
  • string $method: Method name.
overrideMethods (line 1626)

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

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

Documentation generated on Sun, 31 Oct 2010 16:31:48 -0500 by phpDocumentor 1.4.3