PHP Interface FBMock_Mock

ファイルを表示 Open project: facebook/fbmock Interface Usage Examples

Public Methods

Method Description
mockGetCalls ( $method_name ) : array Returns an array representing the invocations of $method_name in the following form:
mockImplementation ( $method_name, $callable ) Replace the implementation of a method with a closure
mockReturn ( ) Force the given method(s) to always return a value
mockReturnThis ( $method1 ) Force the given method(s) to return $this to allow chaining
mockThrow ( $method_name, Exception $e ) Throw exception when method is called

Method Details

mockGetCalls() public method

array( array($param1, $param2, $param3 ...) // first invocation array($param1, $param2, $param3 ...) // second invocation ) Note: see MockAssertionHelpers which has helper methods for asserting calls in tests.
public mockGetCalls ( $method_name ) : array
$method_name name of method to get calls for
return array of invocations

mockImplementation() public method

Replace the implementation of a method with a closure
public mockImplementation ( $method_name, $callable )
$method_name Name of method to replace
$callable New implementation of method. Can be a Closure, string, array(obj, method), etc.

mockReturn() public method

Force the given method(s) to always return a value
public mockReturn ( )

mockReturnThis() public method

Force the given method(s) to return $this to allow chaining
public mockReturnThis ( $method1 )

mockThrow() public method

Throw exception when method is called
public mockThrow ( $method_name, Exception $e )
$method_name name of method
$e Exception exception to throw