PHP 클래스 ShortifyPunit\ShortifyPunit

상속: use trait ShortifyPunit\Matcher\ArgumentMatcher, use trait ShortifyPunit\Mock\MockTrait
파일 보기 프로젝트 열기: danrevah/shortifypunit 1 사용 예제들

공개 메소드들

메소드 설명
__callStatic ( $name, $arguments ) : mixed Call static function is used to detect calls to protected & private methods
getReturnValues ( ) : array
mock ( $mockedClass ) : mixed Mocking interfaces & classes
partialMock ( $mockedClass ) : mixed Partial Mocking interfaces & classes
setReturnValues ( $returnValues )
spy ( $mockedClass )
verify ( $mock ) : ShortifyPunit\Verify\Verify Verifying method interactions
when ( ShortifyPunit\Mock\MockInterface $mock ) : ShortifyPunit\Stub\WhenChainCase Setting up a when case

보호된 메소드들

메소드 설명
_addChainedResponse ( $response ) Adding chained response to ReturnValues array
_createChainResponse ( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, $args ) : null Setting up a chained mock response, function is called from mocked classes
_createResponse ( $className, $instanceId, $methodName, $arguments ) : Mixed | null Create response is a private method which is called from the Mocked classes returns a value which was set before in the When() function otherwise returning NULL
_generateInstanceId ( ) : integer Generating instance id, function is called from mocked classes
_isMethodStubbed ( $className, $instanceId, $methodName ) : boolean Checking if a method with specific arguments has been stubbed
_setWhenMockResponse ( $className, $instanceId, $methodName, $args, $action, $returns ) Setting up a mock response, function is called from mocked classes

비공개 메소드들

메소드 설명
getMockHierarchyResponse ( $chainedMethodsBefore, $mockClassType, $mockClassInstanceId ) : mixed Returns the mock hierarchy response values
getMockReflection ( $mockedClass ) : ReflectionClass

메소드 상세

__callStatic() 공개 정적인 메소드

Call static function is used to detect calls to protected & private methods
public static __callStatic ( $name, $arguments ) : mixed
$name
$arguments
리턴 mixed

_addChainedResponse() 보호된 정적인 메소드

Adding chained response to ReturnValues array
protected static _addChainedResponse ( $response )
$response

_createChainResponse() 보호된 정적인 메소드

Setting up a chained mock response, function is called from mocked classes
protected static _createChainResponse ( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, $args ) : null
$mockClassInstanceId
$mockClassType
$chainedMethodsBefore
$currentMethod
$args
리턴 null

_createResponse() 보호된 정적인 메소드

Create response is a private method which is called from the Mocked classes returns a value which was set before in the When() function otherwise returning NULL
protected static _createResponse ( $className, $instanceId, $methodName, $arguments ) : Mixed | null
$className
$instanceId
$methodName
$arguments
리턴 Mixed | null | null

_generateInstanceId() 보호된 정적인 메소드

Generating instance id, function is called from mocked classes
protected static _generateInstanceId ( ) : integer
리턴 integer

_isMethodStubbed() 보호된 정적인 메소드

Checking if a method with specific arguments has been stubbed
protected static _isMethodStubbed ( $className, $instanceId, $methodName ) : boolean
$className
$instanceId
$methodName
리턴 boolean

_setWhenMockResponse() 보호된 정적인 메소드

Setting up a mock response, function is called from mocked classes
protected static _setWhenMockResponse ( $className, $instanceId, $methodName, $args, $action, $returns )
$className
$instanceId
$methodName
$args
$action
$returns

getReturnValues() 공개 정적인 메소드

public static getReturnValues ( ) : array
리턴 array

mock() 공개 정적인 메소드

Mocking interfaces & classes
public static mock ( $mockedClass ) : mixed
$mockedClass
리턴 mixed

partialMock() 공개 정적인 메소드

Partial Mocking interfaces & classes
public static partialMock ( $mockedClass ) : mixed
$mockedClass
리턴 mixed

setReturnValues() 공개 정적인 메소드

public static setReturnValues ( $returnValues )
$returnValues

spy() 공개 정적인 메소드

사용 중단: use partialMock($mockedClass) instead
public static spy ( $mockedClass )

verify() 공개 정적인 메소드

Examples: ShortifyPunit::when($mock)->first_method()->returns(1); echo $mock->first_method(); // method called once ShortifyPunit::verify($mock)->first_method()->neverCalled(); // returns FALSE ShortifyPunit::verify($mock)->first_method()->atLeast(2); // returns FALSE ShortifyPunit::verify($mock)->first_method()->calledTimes(1); // returns TRUE echo $mock->first_method(); // method has been called twice ShortifyPunit::verify($mock)->first_method()->neverCalled(); // returns FALSE ShortifyPunit::verify($mock)->first_method()->atLeast(2); // returns TRUE ShortifyPunit::verify($mock)->first_method()->calledTimes(2); // returns TRUE
public static verify ( $mock ) : ShortifyPunit\Verify\Verify
$mock
리턴 ShortifyPunit\Verify\Verify

when() 공개 정적인 메소드

Examples: Chain Stubbing ShortifyPunit::when($mock)->first_method()->second_method(1)->returns(1); ShortifyPunit::when($mock)->first_method()->second_method(2)->returns(2); ShortifyPunit::when($mock)->first_method(1)->second_method(1)->returns(3); ShortifyPunit::when($mock)->first_method(2)->second_method(2)->third_method()->returns(4); echo $mock->first_method()->second_method(1); // prints '1' echo $mock->first_method()->second_method(2); // prints '2' echo $mock->first_method(1)->second_method(1); // prints '3' echo $mock->first_method(2)->second_method(2)->third_method(); // prints '4'
public static when ( ShortifyPunit\Mock\MockInterface $mock ) : ShortifyPunit\Stub\WhenChainCase
$mock ShortifyPunit\Mock\MockInterface
리턴 ShortifyPunit\Stub\WhenChainCase