PHP Класс Mockery\Expectation

Наследование: implements mockery\ExpectationInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_actualCount integer Actual count of calls to this expectation
$_closureQueue array Array of closures executed with given arguments to generate a result to be returned
$_countValidatorClass string The count validator class to use
$_countValidators array Count validator store
$_expectedArgs array Arguments expected by this expectation
$_globalOrderNumber integer Integer representing the call order of this expectation on a global basis
$_globally boolean Flag indicating whether the order of calling is determined locally or globally
$_mock object Mock object to which this expectation belongs
$_name string Method name
$_noArgsExpectation boolean Flag indicating we expect no arguments
$_orderNumber integer Integer representing the call order of this expectation
$_passthru boolean Flag indicating if the return value should be obtained from the original class method instead of returning predefined values from the return queue
$_returnQueue array Array of return values as a queue for multiple return sequence
$_returnValue mixed Value to return from this expectation
$_setQueue array Array of values to be set when this expectation matches
$_throw boolean Flag indicating that an exception is expected to be throw (not returned)

Открытые методы

Метод Описание
__clone ( ) Cloning logic
__construct ( Mockery\MockInterface $mock, string $name ) Constructor
__toString ( ) : string Return a string with the method name and arguments formatted
andReturn ( ) : self Set a return value, or sequential queue of return values
andReturnFalse ( )
andReturnNull ( ) : self Return null. This is merely a language construct for Mock describing.
andReturnSelf ( ) : self Return this mock, like a fluent interface
andReturnTrue ( )
andReturnUndefined ( ) : self Return a self-returning black hole object.
andReturnUsing ( ) : self Set a closure or sequence of closures with which to generate return values. The arguments passed to the expected method are passed to the closures as parameters.
andReturnValues ( array $values ) : self Set a sequential queue of return values with an array
andSet ( string $name, mixed $value ) : self Register values to be set to a public property each time this expectation occurs
andThrow ( string | Exception $exception, string $message = '', integer $code, Exception $previous = null ) : self Set Exception class and arguments to that class to be thrown
andThrowExceptions ( array $exceptions ) : self Set Exception classes to be thrown
atLeast ( ) : self Sets next count validator to the AtLeast instance
atMost ( ) : self Sets next count validator to the AtMost instance
between ( integer $minimum, integer $maximum ) Shorthand for setting minimum and maximum constraints on call counts
byDefault ( ) : self Mark this expectation as being a default
getMock ( ) : Mockery\MockInterface Return the parent mock of the expectation
getName ( )
getOrderNumber ( ) : integer Return order number
globally ( ) : self Indicates call order should apply globally
isCallCountConstrained ( ) : boolean Check if there is a constraint on call count
isEligible ( ) : boolean Checks if this expectation is eligible for additional calls
matchArgs ( array $args ) : boolean Check if passed arguments match an argument expectation
never ( ) : self Indicates that this expectation is never expected to be called
once ( ) : self Indicates that this expectation is expected exactly once
ordered ( string $group = null ) : self Indicates that this expectation must be called in a specific given order
passthru ( ) : self Flag this expectation as calling the original class method with the any provided arguments instead of using a return value queue.
set ( string $name, mixed $value ) : self Alias to andSet(). Allows the natural English construct - set('foo', 'bar')->andReturn('bar')
times ( integer $limit = null ) : self Indicates the number of times this expectation should occur
twice ( ) : self Indicates that this expectation is expected exactly twice
validateOrder ( ) : void Verify call order
verify ( ) : boolean Verify this expectation
verifyCall ( array $args ) : mixed Verify the current call, i.e. that the given arguments match those of this expectation
with ( ) : self Expected argument setter for the expectation
withAnyArgs ( ) : self Set expectation that any arguments are acceptable
withArgs ( array | Closur\Closure $argsOrClosure ) : self Expected arguments for the expectation passed as an array or a closure that matches each passed argument on each function call.
withNoArgs ( ) : self Set with() as no arguments expected
zeroOrMoreTimes ( ) : self Indicates this expectation should occur zero or more times

Защищенные методы

Метод Описание
_defineOrdered ( string $group, object $ordering ) : integer Setup the ordering tracking on the mock or mock container
_getReturnValue ( array $args ) : mixed Fetch the return value for the matching args
_matchArg ( mixed $expected, &$actual ) : boolean Check if passed argument matches an argument expectation
_setValues ( ) : mixed Sets public properties with queued values to the mock object

Приватные методы

Метод Описание
isMultiArgumentClosureExpectation ( ) : boolean Check if the registered expectation is a MultiArgumentClosureExpectation.
withArgsInArray ( array $arguments ) : self Expected arguments for the expectation passed as an array
withArgsMatchedByClosure ( Closur\Closure $closure ) : self Expected arguments have to be matched by the given closure.

Описание методов

__clone() публичный Метод

Cloning logic
public __clone ( )

__construct() публичный Метод

Constructor
public __construct ( Mockery\MockInterface $mock, string $name )
$mock Mockery\MockInterface
$name string

__toString() публичный Метод

Return a string with the method name and arguments formatted
public __toString ( ) : string
Результат string

_defineOrdered() защищенный Метод

Setup the ordering tracking on the mock or mock container
protected _defineOrdered ( string $group, object $ordering ) : integer
$group string
$ordering object
Результат integer

_getReturnValue() защищенный Метод

Fetch the return value for the matching args
protected _getReturnValue ( array $args ) : mixed
$args array
Результат mixed

_matchArg() защищенный Метод

Check if passed argument matches an argument expectation
protected _matchArg ( mixed $expected, &$actual ) : boolean
$expected mixed
Результат boolean

_setValues() защищенный Метод

Sets public properties with queued values to the mock object
protected _setValues ( ) : mixed
Результат mixed

andReturn() публичный Метод

Set a return value, or sequential queue of return values
public andReturn ( ) : self
Результат self

andReturnFalse() публичный Метод

public andReturnFalse ( )

andReturnNull() публичный Метод

Return null. This is merely a language construct for Mock describing.
public andReturnNull ( ) : self
Результат self

andReturnSelf() публичный Метод

Return this mock, like a fluent interface
public andReturnSelf ( ) : self
Результат self

andReturnTrue() публичный Метод

public andReturnTrue ( )

andReturnUndefined() публичный Метод

Return a self-returning black hole object.
public andReturnUndefined ( ) : self
Результат self

andReturnUsing() публичный Метод

Set a closure or sequence of closures with which to generate return values. The arguments passed to the expected method are passed to the closures as parameters.
public andReturnUsing ( ) : self
Результат self

andReturnValues() публичный Метод

Set a sequential queue of return values with an array
public andReturnValues ( array $values ) : self
$values array
Результат self

andSet() публичный Метод

Register values to be set to a public property each time this expectation occurs
public andSet ( string $name, mixed $value ) : self
$name string
$value mixed
Результат self

andThrow() публичный Метод

Set Exception class and arguments to that class to be thrown
public andThrow ( string | Exception $exception, string $message = '', integer $code, Exception $previous = null ) : self
$exception string | Exception
$message string
$code integer
$previous Exception
Результат self

andThrowExceptions() публичный Метод

Set Exception classes to be thrown
public andThrowExceptions ( array $exceptions ) : self
$exceptions array
Результат self

atLeast() публичный Метод

Sets next count validator to the AtLeast instance
public atLeast ( ) : self
Результат self

atMost() публичный Метод

Sets next count validator to the AtMost instance
public atMost ( ) : self
Результат self

between() публичный Метод

Shorthand for setting minimum and maximum constraints on call counts
public between ( integer $minimum, integer $maximum )
$minimum integer
$maximum integer

byDefault() публичный Метод

Mark this expectation as being a default
public byDefault ( ) : self
Результат self

getMock() публичный Метод

Return the parent mock of the expectation
public getMock ( ) : Mockery\MockInterface
Результат Mockery\MockInterface

getName() публичный Метод

public getName ( )

getOrderNumber() публичный Метод

Return order number
public getOrderNumber ( ) : integer
Результат integer

globally() публичный Метод

Indicates call order should apply globally
public globally ( ) : self
Результат self

isCallCountConstrained() публичный Метод

Check if there is a constraint on call count
public isCallCountConstrained ( ) : boolean
Результат boolean

isEligible() публичный Метод

Checks if this expectation is eligible for additional calls
public isEligible ( ) : boolean
Результат boolean

matchArgs() публичный Метод

Check if passed arguments match an argument expectation
public matchArgs ( array $args ) : boolean
$args array
Результат boolean

never() публичный Метод

Indicates that this expectation is never expected to be called
public never ( ) : self
Результат self

once() публичный Метод

Indicates that this expectation is expected exactly once
public once ( ) : self
Результат self

ordered() публичный Метод

Indicates that this expectation must be called in a specific given order
public ordered ( string $group = null ) : self
$group string Name of the ordered group
Результат self

passthru() публичный Метод

Flag this expectation as calling the original class method with the any provided arguments instead of using a return value queue.
public passthru ( ) : self
Результат self

set() публичный Метод

Alias to andSet(). Allows the natural English construct - set('foo', 'bar')->andReturn('bar')
public set ( string $name, mixed $value ) : self
$name string
$value mixed
Результат self

times() публичный Метод

Indicates the number of times this expectation should occur
public times ( integer $limit = null ) : self
$limit integer
Результат self

twice() публичный Метод

Indicates that this expectation is expected exactly twice
public twice ( ) : self
Результат self

validateOrder() публичный Метод

Verify call order
public validateOrder ( ) : void
Результат void

verify() публичный Метод

Verify this expectation
public verify ( ) : boolean
Результат boolean

verifyCall() публичный Метод

Verify the current call, i.e. that the given arguments match those of this expectation
public verifyCall ( array $args ) : mixed
$args array
Результат mixed

with() публичный Метод

Expected argument setter for the expectation
public with ( ) : self
Результат self

withAnyArgs() публичный Метод

Set expectation that any arguments are acceptable
public withAnyArgs ( ) : self
Результат self

withArgs() публичный Метод

Expected arguments for the expectation passed as an array or a closure that matches each passed argument on each function call.
public withArgs ( array | Closur\Closure $argsOrClosure ) : self
$argsOrClosure array | Closur\Closure
Результат self

withNoArgs() публичный Метод

Set with() as no arguments expected
public withNoArgs ( ) : self
Результат self

zeroOrMoreTimes() публичный Метод

Indicates this expectation should occur zero or more times
public zeroOrMoreTimes ( ) : self
Результат self

Описание свойств

$_actualCount защищенное свойство

Actual count of calls to this expectation
protected int $_actualCount
Результат integer

$_closureQueue защищенное свойство

Array of closures executed with given arguments to generate a result to be returned
protected array $_closureQueue
Результат array

$_countValidatorClass защищенное свойство

The count validator class to use
protected string $_countValidatorClass
Результат string

$_countValidators защищенное свойство

Count validator store
protected array $_countValidators
Результат array

$_expectedArgs защищенное свойство

Arguments expected by this expectation
protected array $_expectedArgs
Результат array

$_globalOrderNumber защищенное свойство

Integer representing the call order of this expectation on a global basis
protected int $_globalOrderNumber
Результат integer

$_globally защищенное свойство

Flag indicating whether the order of calling is determined locally or globally
protected bool $_globally
Результат boolean

$_mock защищенное свойство

Mock object to which this expectation belongs
protected object $_mock
Результат object

$_name защищенное свойство

Method name
protected string $_name
Результат string

$_noArgsExpectation защищенное свойство

Flag indicating we expect no arguments
protected bool $_noArgsExpectation
Результат boolean

$_orderNumber защищенное свойство

Integer representing the call order of this expectation
protected int $_orderNumber
Результат integer

$_passthru защищенное свойство

Flag indicating if the return value should be obtained from the original class method instead of returning predefined values from the return queue
protected bool $_passthru
Результат boolean

$_returnQueue защищенное свойство

Array of return values as a queue for multiple return sequence
protected array $_returnQueue
Результат array

$_returnValue защищенное свойство

Value to return from this expectation
protected mixed $_returnValue
Результат mixed

$_setQueue защищенное свойство

Array of values to be set when this expectation matches
protected array $_setQueue
Результат array

$_throw защищенное свойство

Flag indicating that an exception is expected to be throw (not returned)
protected bool $_throw
Результат boolean