PHP Class Mockery\Mock

Inheritance: implements Mockery\MockInterface
显示文件 Open project: padraic/mockery Class Usage Examples

Protected Properties

Property Type Description
$_mockery_allocatedOrder integer Order number of allocation
$_mockery_allowMockingProtectedMethods
$_mockery_container Container Mock container containing this mock object
$_mockery_currentOrder integer Current ordered number
$_mockery_defaultReturnValue mixed If shouldIgnoreMissing is called, this value will be returned on all calls to missing methods
$_mockery_deferMissing boolean Flag to indicate whether we can defer method calls missing from our expectations
$_mockery_disableExpectationMatching boolean Flag to indicate we should ignore all expectations temporarily. Used mainly to prevent expectation matching when in the middle of a mock object recording session.
$_mockery_expectations array Stores an array of all expectation directors for this mock
$_mockery_expectations_count integer Stores an inital number of expectations that can be manipulated while using the getter method.
$_mockery_groups array Ordered groups
$_mockery_ignoreMissing boolean Flag to indicate whether we can ignore method calls missing from our expectations
$_mockery_methods ReflectionMethod[] Just a local cache for this mock's target's methods
$_mockery_mockableMethods array
$_mockery_mockableProperties array Stores all stubbed public methods separate from any on-object public properties that may exist.
$_mockery_name string Given name of the mock
$_mockery_partial object Instance of a core object on which methods are called in the event it has been set, and an expectation for one of the object's methods does not exist. This implements a simple partial mock proxy system.
$_mockery_receivedMethodCalls
$_mockery_verified boolean Flag to indicate whether this mock was verified

Public Methods

Method Description
__call ( $method, array $args ) Capture calls to this mock
__callStatic ( $method, array $args )
__destruct ( )
__isset ( $name )
__toString ( ) Forward calls to this magic method to the __call method
__wakeup ( )
asUndefined ( )
byDefault ( ) : self In the event shouldReceive() accepting one or more methods/returns, this method will switch them from normal expectations to default expectations
makePartial ( ) : Mock Create an obviously worded alias to shouldDeferMissing()
mockery_allocateOrder ( ) : integer Fetch the next available allocation order number
mockery_callSubjectMethod ( string $name, array $args ) : mixed Calls a parent class method and returns the result. Used in a passthru expectation where a real return value is required while still taking advantage of expectation matching and call count verification.
mockery_findExpectation ( $method, array $args ) : Expectation | null Find an expectation matching the given method and arguments
mockery_getContainer ( ) : Container Return the container for this mock
mockery_getCurrentOrder ( ) : integer Get current ordered number
mockery_getExpectationCount ( ) : integer Gets the count of expectations for this mock
mockery_getExpectations ( )
mockery_getExpectationsFor ( $method ) : Mockery\ExpectationDirector | null Return the expectations director for the given method
mockery_getGroups ( ) : array Fetch array of ordered groups
mockery_getMethod ( $name )
mockery_getMockableMethods ( ) : string[]
mockery_getMockableProperties ( ) : array
mockery_getName ( ) : string Return the name for this mock
mockery_init ( Container $container = null, object $partialObject = null ) : void We want to avoid constructors since class is copied to Generator.php for inclusion on extending class definitions.
mockery_isAnonymous ( ) : boolean
mockery_returnValueForMethod ( string $name ) : mixed
mockery_setCurrentOrder ( integer $order ) Set current ordered number
mockery_setExpectationsFor ( $method, Mockery\ExpectationDirector $director ) : Mockery\ExpectationDirector | null Return the expectations director for the given method
mockery_setGroup ( mixed $group, integer $order ) Set ordering for a group
mockery_teardown ( ) : void Tear down tasks for this mock
mockery_validateOrder ( string $method, integer $order ) : void Validate the current mock's ordering
mockery_verify ( ) : void Iterate across all expectation directors and validate each
shouldAllowMockingMethod ( String $method ) : Mock Allows additional methods to be mocked that do not explicitly exist on mocked class
shouldAllowMockingProtectedMethods ( ) : Mock
shouldDeferMissing ( ) : Mock Set mock to defer unexpected methods to it's parent
shouldExpect ( Closure $closure ) Accepts a closure which is executed with an object recorder which proxies to the partial source object. The intent being to record the interactions of a concrete object as a set of expectations on the current mock object. The partial may then be passed to a second process to see if it fulfils the same (or exact same) contract as the original.
shouldHaveReceived ( $method, $args = null )
shouldIgnoreMissing ( mixed $returnValue = null ) : Mock Set mock to ignore unexpected methods and return Undefined class
shouldNotHaveReceived ( $method, $args = null )
shouldNotReceive ( $methodName ) : Expectation Shortcut method for setting an expectation that a method should not be called.
shouldReceive ( $methodName ) : Expectation Set expected method calls

Protected Methods

Method Description
_mockery_getReceivedMethodCalls ( )
_mockery_handleMethodCall ( $method, array $args )
_mockery_handleStaticMethodCall ( $method, array $args )
mockery_getMethods ( ) : array Uses reflection to get the list of all methods within the current mock object

Private Methods

Method Description
getNonPublicMethods ( ) : array
hasMethodOverloadingInParentClass ( )

Method Details

__call() public method

Capture calls to this mock
public __call ( $method, array $args )
$args array

__callStatic() public static method

public static __callStatic ( $method, array $args )
$args array

__destruct() public method

public __destruct ( )

__isset() public method

public __isset ( $name )

__toString() public method

Forward calls to this magic method to the __call method
public __toString ( )

__wakeup() public method

public __wakeup ( )

_mockery_getReceivedMethodCalls() protected method

_mockery_handleMethodCall() protected method

protected _mockery_handleMethodCall ( $method, array $args )
$args array

_mockery_handleStaticMethodCall() protected static method

protected static _mockery_handleStaticMethodCall ( $method, array $args )
$args array

asUndefined() public method

public asUndefined ( )

byDefault() public method

In the event shouldReceive() accepting one or more methods/returns, this method will switch them from normal expectations to default expectations
public byDefault ( ) : self
return self

makePartial() public method

Create an obviously worded alias to shouldDeferMissing()
public makePartial ( ) : Mock
return Mock

mockery_allocateOrder() public method

Fetch the next available allocation order number
public mockery_allocateOrder ( ) : integer
return integer

mockery_callSubjectMethod() public method

Calls a parent class method and returns the result. Used in a passthru expectation where a real return value is required while still taking advantage of expectation matching and call count verification.
public mockery_callSubjectMethod ( string $name, array $args ) : mixed
$name string
$args array
return mixed

mockery_findExpectation() public method

Find an expectation matching the given method and arguments
public mockery_findExpectation ( $method, array $args ) : Expectation | null
$args array
return Expectation | null

mockery_getContainer() public method

Return the container for this mock
public mockery_getContainer ( ) : Container
return Container

mockery_getCurrentOrder() public method

Get current ordered number

mockery_getExpectationCount() public method

Gets the count of expectations for this mock

mockery_getExpectations() public method

mockery_getExpectationsFor() public method

Return the expectations director for the given method
public mockery_getExpectationsFor ( $method ) : Mockery\ExpectationDirector | null
return Mockery\ExpectationDirector | null

mockery_getGroups() public method

Fetch array of ordered groups
public mockery_getGroups ( ) : array
return array

mockery_getMethod() public method

public mockery_getMethod ( $name )

mockery_getMethods() protected method

Uses reflection to get the list of all methods within the current mock object
protected mockery_getMethods ( ) : array
return array

mockery_getMockableMethods() public method

public mockery_getMockableMethods ( ) : string[]
return string[]

mockery_getMockableProperties() public method

mockery_getName() public method

Return the name for this mock
public mockery_getName ( ) : string
return string

mockery_init() public method

We want to avoid constructors since class is copied to Generator.php for inclusion on extending class definitions.
public mockery_init ( Container $container = null, object $partialObject = null ) : void
$container Container
$partialObject object
return void

mockery_isAnonymous() public method

public mockery_isAnonymous ( ) : boolean
return boolean

mockery_returnValueForMethod() public method

public mockery_returnValueForMethod ( string $name ) : mixed
$name string Method name.
return mixed Generated return value based on the declared return value of the named method.

mockery_setCurrentOrder() public method

Set current ordered number
public mockery_setCurrentOrder ( integer $order )
$order integer

mockery_setExpectationsFor() public method

Return the expectations director for the given method
public mockery_setExpectationsFor ( $method, Mockery\ExpectationDirector $director ) : Mockery\ExpectationDirector | null
$director Mockery\ExpectationDirector
return Mockery\ExpectationDirector | null

mockery_setGroup() public method

Set ordering for a group
public mockery_setGroup ( mixed $group, integer $order )
$group mixed
$order integer

mockery_teardown() public method

Tear down tasks for this mock
public mockery_teardown ( ) : void
return void

mockery_validateOrder() public method

Validate the current mock's ordering
public mockery_validateOrder ( string $method, integer $order ) : void
$method string
$order integer
return void

mockery_verify() public method

Iterate across all expectation directors and validate each
public mockery_verify ( ) : void
return void

shouldAllowMockingMethod() public method

Allows additional methods to be mocked that do not explicitly exist on mocked class
public shouldAllowMockingMethod ( String $method ) : Mock
$method String name of the method to be mocked
return Mock

shouldAllowMockingProtectedMethods() public method

public shouldAllowMockingProtectedMethods ( ) : Mock
return Mock

shouldDeferMissing() public method

This is particularly useless for this class, as it doesn't have a parent, but included for completeness
public shouldDeferMissing ( ) : Mock
return Mock

shouldExpect() public method

Accepts a closure which is executed with an object recorder which proxies to the partial source object. The intent being to record the interactions of a concrete object as a set of expectations on the current mock object. The partial may then be passed to a second process to see if it fulfils the same (or exact same) contract as the original.
public shouldExpect ( Closure $closure )
$closure Closure

shouldHaveReceived() public method

public shouldHaveReceived ( $method, $args = null )

shouldIgnoreMissing() public method

Set mock to ignore unexpected methods and return Undefined class
public shouldIgnoreMissing ( mixed $returnValue = null ) : Mock
$returnValue mixed the default return value for calls to missing functions on this mock
return Mock

shouldNotHaveReceived() public method

public shouldNotHaveReceived ( $method, $args = null )

shouldNotReceive() public method

Shortcut method for setting an expectation that a method should not be called.
public shouldNotReceive ( $methodName ) : Expectation
return Expectation

shouldReceive() public method

Set expected method calls
public shouldReceive ( $methodName ) : Expectation
return Expectation

Property Details

$_mockery_allocatedOrder protected_oe property

Order number of allocation
protected int $_mockery_allocatedOrder
return integer

$_mockery_allowMockingProtectedMethods protected_oe property

protected $_mockery_allowMockingProtectedMethods

$_mockery_container protected_oe property

Mock container containing this mock object
protected Container,Mockery $_mockery_container
return Container

$_mockery_currentOrder protected_oe property

Current ordered number
protected int $_mockery_currentOrder
return integer

$_mockery_defaultReturnValue protected_oe property

If shouldIgnoreMissing is called, this value will be returned on all calls to missing methods
protected mixed $_mockery_defaultReturnValue
return mixed

$_mockery_deferMissing protected_oe property

Flag to indicate whether we can defer method calls missing from our expectations
protected bool $_mockery_deferMissing
return boolean

$_mockery_disableExpectationMatching protected_oe property

Flag to indicate we should ignore all expectations temporarily. Used mainly to prevent expectation matching when in the middle of a mock object recording session.
protected bool $_mockery_disableExpectationMatching
return boolean

$_mockery_expectations protected_oe property

Stores an array of all expectation directors for this mock
protected array $_mockery_expectations
return array

$_mockery_expectations_count protected_oe property

Stores an inital number of expectations that can be manipulated while using the getter method.
protected int $_mockery_expectations_count
return integer

$_mockery_groups protected_oe property

Ordered groups
protected array $_mockery_groups
return array

$_mockery_ignoreMissing protected_oe property

Flag to indicate whether we can ignore method calls missing from our expectations
protected bool $_mockery_ignoreMissing
return boolean

$_mockery_methods protected_oe static_oe property

Just a local cache for this mock's target's methods
protected static ReflectionMethod[] $_mockery_methods
return ReflectionMethod[]

$_mockery_mockableMethods protected_oe property

protected array $_mockery_mockableMethods
return array

$_mockery_mockableProperties protected_oe property

Stores all stubbed public methods separate from any on-object public properties that may exist.
protected array $_mockery_mockableProperties
return array

$_mockery_name protected_oe property

Given name of the mock
protected string $_mockery_name
return string

$_mockery_partial protected_oe property

Instance of a core object on which methods are called in the event it has been set, and an expectation for one of the object's methods does not exist. This implements a simple partial mock proxy system.
protected object $_mockery_partial
return object

$_mockery_receivedMethodCalls protected_oe property

protected $_mockery_receivedMethodCalls

$_mockery_verified protected_oe property

Flag to indicate whether this mock was verified
protected bool $_mockery_verified
return boolean