PHP 클래스 MockGenerator, simpletest

@package SimpleTest
파일 보기 프로젝트 열기: simpletest/simpletest 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( string $class, string $mock_class ) Builds initial reflection object.
generate ( array $methods ) Clones a class' interface and creates a mock version that can have return values and expectations set.
generatePartial ( array $methods ) Generates a version of a class with selected methods mocked only.
generateSubclass ( array $methods ) Subclasses a class and overrides every method with a mock one that can have return values and expectations set.

보호된 메소드들

메소드 설명
addMethodList ( array $methods ) : string Creates a list of mocked methods for error checking.
bailOutIfNotMocked ( string $alias ) : string Creates code to abandon the expectation if not mocked.
chainMockExpectations ( ) : string Creates source code for chaining to an aggregated mock object.
chainMockReturns ( ) : string Creates source code for chaining to the composited mock object.
chainThrowMethods ( ) : string Adds code for chaining the throw methods.
createClassCode ( array $methods ) : string The new mock class code as a string.
createConstructorCode ( ) : string Creates source code for late calling the constructor of the composited mock object.
createHandlerCode ( array $methods ) Creates code within a class to generate replaced methods.
createNewMethodCode ( array $methods ) Creates code within a class to generate a newmethods.
createSubclassCode ( array $methods ) : string The new mock class code as a string.
extendClassCode ( array $methods ) : string The extension class code as a string.
isConstructorOrDeconstructor ( string $method ) : boolean Tests to see if a special PHP method is about to be stubbed by mistake.
overrideMethods ( array $methods ) : string Creates source code to override a list of methods with mock versions.

메소드 상세

__construct() 공개 메소드

Builds initial reflection object.
public __construct ( string $class, string $mock_class )
$class string Class to be mocked.
$mock_class string New class with identical interface, but no behaviour.

addMethodList() 보호된 메소드

Creates a list of mocked methods for error checking.
protected addMethodList ( array $methods ) : string
$methods array Mocked methods.
리턴 string Code for a method list.

bailOutIfNotMocked() 보호된 메소드

Creates code to abandon the expectation if not mocked.
protected bailOutIfNotMocked ( string $alias ) : string
$alias string Parameter name of method name.
리턴 string Code for bail out.

chainMockExpectations() 보호된 메소드

Creates source code for chaining to an aggregated mock object.
protected chainMockExpectations ( ) : string
리턴 string Code for expectations.

chainMockReturns() 보호된 메소드

Creates source code for chaining to the composited mock object.
protected chainMockReturns ( ) : string
리턴 string Code for mock set up.

chainThrowMethods() 보호된 메소드

Adds code for chaining the throw methods.
protected chainThrowMethods ( ) : string
리턴 string Code for chains.

createClassCode() 보호된 메소드

The new mock class code as a string.
protected createClassCode ( array $methods ) : string
$methods array Additional methods.
리턴 string Code for new mock class.

createConstructorCode() 보호된 메소드

Creates source code for late calling the constructor of the composited mock object.
protected createConstructorCode ( ) : string
리턴 string Code for late calls.

createHandlerCode() 보호된 메소드

All methods call the invoke() handler with the method name and the arguments in an array.
protected createHandlerCode ( array $methods )
$methods array Additional methods.

createNewMethodCode() 보호된 메소드

All methods call the invoke() handler on the internal mock with the method name and the arguments in an array.
protected createNewMethodCode ( array $methods )
$methods array Additional methods.

createSubclassCode() 보호된 메소드

The mock will be a subclass of the original mocked class.
protected createSubclassCode ( array $methods ) : string
$methods array Additional methods.
리턴 string Code for new mock class.

extendClassCode() 보호된 메소드

The class composites a mock object and chains mocked methods to it.
protected extendClassCode ( array $methods ) : string
$methods array Mocked methods.
리턴 string Code for a new class.

generate() 공개 메소드

Clones a class' interface and creates a mock version that can have return values and expectations set.
public generate ( array $methods )
$methods array 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() 공개 메소드

Inherits the old class and chains the mock methods of an aggregated mock object.
public generatePartial ( array $methods )
$methods array Methods to be overridden with mock versions.

generateSubclass() 공개 메소드

Chains to an aggregated SimpleMock.
public generateSubclass ( array $methods )
$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.

isConstructorOrDeconstructor() 보호된 메소드

Tests to see if a special PHP method is about to be stubbed by mistake.
protected isConstructorOrDeconstructor ( string $method ) : boolean
$method string Method name.
리턴 boolean True if special.

overrideMethods() 보호된 메소드

Creates source code to override a list of methods with mock versions.
protected overrideMethods ( array $methods ) : string
$methods array Methods to be overridden with mock versions.
리턴 string Code for overridden chains.