PHP Class Mock, simpletest

@package SimpleTest
Datei anzeigen Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method Description
__construct ( ) Factory for mock object classes.
generate ( string $class, string $mock_class = false, array $methods = false ) Clones a class' interface and creates a mock version that can have return values and expectations set.
generatePartial ( string $class, string $mock_class, array $methods ) Generates a version of a class with selected methods mocked only.
getExpectationLine ( ) Uses a stack trace to find the line of an assertion.

Method Details

__construct() public method

Factory for mock object classes.
public __construct ( )

generate() public static method

Clones a class' interface and creates a mock version that can have return values and expectations set.
public static generate ( string $class, string $mock_class = false, array $methods = false )
$class string Class to clone.
$mock_class string New class name. Default is the old name with "Mock" prepended.
$methods array 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.sta

generatePartial() public static method

Inherits the old class and chains the mock methods of an aggregated mock object.
public static generatePartial ( string $class, string $mock_class, array $methods )
$class string Class to clone.
$mock_class string New class name.
$methods array Methods to be overridden with mock versions.

getExpectationLine() public static method

Uses a stack trace to find the line of an assertion.
public static getExpectationLine ( )