PHP Class Eloquent\Phony\Spy\SpyVerifier

Inheritance: extends Eloquent\Phony\Verification\AbstractCardinalityVerifier, implements Eloquent\Phony\Spy\Spy
Datei anzeigen Open project: eloquent/phony Class Usage Examples

Public Methods

Method Description
__construct ( Eloquent\Phony\Spy\Spy $spy, MatcherFactory $matcherFactory, MatcherVerifier $matcherVerifier, GeneratorVerifierFactory $generatorVerifierFactory, IterableVerifierFactory $iterableVerifierFactory, CallVerifierFactory $callVerifierFactory, Eloquent\Phony\Assertion\AssertionRecorder $assertionRecorder, AssertionRenderer $assertionRenderer ) Construct a new spy verifier.
__invoke ( ) : mixed Invoke this object.
addCall ( Eloquent\Phony\Call\Call $call ) Add a call.
allCalls ( ) : array Get all calls as an array.
allEvents ( ) : array Get all events as an array.
callAt ( integer $index ) : CallVerifier Get a call by index.
callCount ( ) : integer Get the number of calls.
callback ( ) : callable Get the callback.
called ( ) : Eloquent\Phony\Event\EventCollection Throws an exception unless called.
calledWith ( ) : Eloquent\Phony\Event\EventCollection Throws an exception unless called with the supplied arguments.
checkCalled ( ) : Eloquent\Phony\Event\EventCollection | null Checks if called.
checkCalledWith ( ) : Eloquent\Phony\Event\EventCollection | null Checks if called with the supplied arguments.
checkCompleted ( ) : Eloquent\Phony\Event\EventCollection | null Checks if this spy completed.
checkGenerated ( ) : GeneratorVerifier | null Checks if this spy returned a generator.
checkIterated ( ) : IterableVerifier | null Checks if this spy returned an iterable.
checkResponded ( ) : Eloquent\Phony\Event\EventCollection | null Checks if this spy responded.
checkReturned ( mixed $value = null ) : Eloquent\Phony\Event\EventCollection | null Checks if this spy returned the supplied value.
checkThrew ( Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null $type = null ) : Eloquent\Phony\Event\EventCollection | null Checks if an exception of the supplied type was thrown.
completed ( ) : Eloquent\Phony\Event\EventCollection Throws an exception unless this spy completed.
count ( ) : integer Get the event count.
eventAt ( integer $index ) : Eloquent\Phony\Event\Event Get an event by index.
eventCount ( ) : integer Get the number of events.
firstCall ( ) : Eloquent\Phony\Call\Call Get the first call.
firstEvent ( ) : Eloquent\Phony\Event\Event Get the first event.
generated ( ) : GeneratorVerifier Throws an exception unless this spy returned a generator.
getIterator ( ) : Iterator Get an iterator for this collection.
hasCalls ( ) : boolean Returns true if this collection contains any calls.
hasEvents ( ) : boolean Returns true if this collection contains any events.
invoke ( ) : mixed Invoke this object.
invokeWith ( Arguments | array $arguments = [] ) : mixed Invoke this object.
isAnonymous ( ) : boolean Returns true if anonymous.
iterated ( ) : IterableVerifier Throws an exception unless this spy returned an iterable.
label ( ) : string | null Get the label.
lastCall ( ) : Eloquent\Phony\Call\Call Get the last call.
lastEvent ( ) : Eloquent\Phony\Event\Event Get the last event.
responded ( ) : Eloquent\Phony\Event\EventCollection Throws an exception unless this spy responded.
returned ( mixed $value = null ) : Eloquent\Phony\Event\EventCollection Throws an exception unless this spy returned the supplied value.
setCalls ( array $calls ) Set the calls.
setLabel ( string | null $label ) Set the label.
setUseGeneratorSpies ( boolean $useGeneratorSpies ) Turn on or off the use of generator spies.
setUseIterableSpies ( boolean $useIterableSpies ) Turn on or off the use of iterable spies.
spy ( ) : Eloquent\Phony\Spy\Spy Get the spy.
startRecording ( ) Start recording calls.
stopRecording ( ) Stop recording calls.
threw ( Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null $type = null ) : Eloquent\Phony\Event\EventCollection Throws an exception unless an exception of the supplied type was thrown.
useGeneratorSpies ( ) : boolean Returns true if this spy uses generator spies.
useIterableSpies ( ) : boolean Returns true if this spy uses iterable spies.

Method Details

__construct() public method

Construct a new spy verifier.
public __construct ( Eloquent\Phony\Spy\Spy $spy, MatcherFactory $matcherFactory, MatcherVerifier $matcherVerifier, GeneratorVerifierFactory $generatorVerifierFactory, IterableVerifierFactory $iterableVerifierFactory, CallVerifierFactory $callVerifierFactory, Eloquent\Phony\Assertion\AssertionRecorder $assertionRecorder, AssertionRenderer $assertionRenderer )
$spy Eloquent\Phony\Spy\Spy The spy.
$matcherFactory Eloquent\Phony\Matcher\MatcherFactory The matcher factory to use.
$matcherVerifier Eloquent\Phony\Matcher\MatcherVerifier The macther verifier to use.
$generatorVerifierFactory Eloquent\Phony\Verification\GeneratorVerifierFactory The generator verifier factory to use.
$iterableVerifierFactory Eloquent\Phony\Verification\IterableVerifierFactory The iterable verifier factory to use.
$callVerifierFactory Eloquent\Phony\Call\CallVerifierFactory The call verifier factory to use.
$assertionRecorder Eloquent\Phony\Assertion\AssertionRecorder The assertion recorder to use.
$assertionRenderer Eloquent\Phony\Assertion\AssertionRenderer The assertion renderer to use.

__invoke() public method

Invoke this object.
public __invoke ( ) : mixed
return mixed The result of invocation.

addCall() public method

Add a call.
public addCall ( Eloquent\Phony\Call\Call $call )
$call Eloquent\Phony\Call\Call The call.

allCalls() public method

Get all calls as an array.
public allCalls ( ) : array
return array

allEvents() public method

Get all events as an array.
public allEvents ( ) : array
return array

callAt() public method

Negative indices are offset from the end of the list. That is, -1 indicates the last element, and -2 indicates the second last element.
public callAt ( integer $index ) : CallVerifier
$index integer The index.
return Eloquent\Phony\Call\CallVerifier The call.

callCount() public method

Get the number of calls.
public callCount ( ) : integer
return integer The call count.

callback() public method

Get the callback.
public callback ( ) : callable
return callable The callback.

called() public method

Throws an exception unless called.
public called ( ) : Eloquent\Phony\Event\EventCollection
return Eloquent\Phony\Event\EventCollection The result.

calledWith() public method

Throws an exception unless called with the supplied arguments.
public calledWith ( ) : Eloquent\Phony\Event\EventCollection
return Eloquent\Phony\Event\EventCollection The result.

checkCalled() public method

Checks if called.
public checkCalled ( ) : Eloquent\Phony\Event\EventCollection | null
return Eloquent\Phony\Event\EventCollection | null The result.

checkCalledWith() public method

Checks if called with the supplied arguments.
public checkCalledWith ( ) : Eloquent\Phony\Event\EventCollection | null
return Eloquent\Phony\Event\EventCollection | null The result.

checkCompleted() public method

Checks if this spy completed.
public checkCompleted ( ) : Eloquent\Phony\Event\EventCollection | null
return Eloquent\Phony\Event\EventCollection | null The result.

checkGenerated() public method

Checks if this spy returned a generator.
public checkGenerated ( ) : GeneratorVerifier | null
return Eloquent\Phony\Verification\GeneratorVerifier | null The result.

checkIterated() public method

Checks if this spy returned an iterable.
public checkIterated ( ) : IterableVerifier | null
return Eloquent\Phony\Verification\IterableVerifier | null The result.

checkResponded() public method

Checks if this spy responded.
public checkResponded ( ) : Eloquent\Phony\Event\EventCollection | null
return Eloquent\Phony\Event\EventCollection | null The result.

checkReturned() public method

Checks if this spy returned the supplied value.
public checkReturned ( mixed $value = null ) : Eloquent\Phony\Event\EventCollection | null
$value mixed The value.
return Eloquent\Phony\Event\EventCollection | null The result.

checkThrew() public method

Checks if an exception of the supplied type was thrown.
public checkThrew ( Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null $type = null ) : Eloquent\Phony\Event\EventCollection | null
$type Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null An exception to match, the type of exception, or null for any exception.
return Eloquent\Phony\Event\EventCollection | null The result.

completed() public method

Throws an exception unless this spy completed.
public completed ( ) : Eloquent\Phony\Event\EventCollection
return Eloquent\Phony\Event\EventCollection The result.

count() public method

Get the event count.
public count ( ) : integer
return integer The event count.

eventAt() public method

Negative indices are offset from the end of the list. That is, -1 indicates the last element, and -2 indicates the second last element.
public eventAt ( integer $index ) : Eloquent\Phony\Event\Event
$index integer The index.
return Eloquent\Phony\Event\Event The event.

eventCount() public method

Get the number of events.
public eventCount ( ) : integer
return integer The event count.

firstCall() public method

Get the first call.
public firstCall ( ) : Eloquent\Phony\Call\Call
return Eloquent\Phony\Call\Call The call.

firstEvent() public method

Get the first event.
public firstEvent ( ) : Eloquent\Phony\Event\Event
return Eloquent\Phony\Event\Event The event.

generated() public method

Throws an exception unless this spy returned a generator.
public generated ( ) : GeneratorVerifier
return Eloquent\Phony\Verification\GeneratorVerifier The result.

getIterator() public method

Get an iterator for this collection.
public getIterator ( ) : Iterator
return Iterator The iterator.

hasCalls() public method

Returns true if this collection contains any calls.
public hasCalls ( ) : boolean
return boolean True if this collection contains any calls.

hasEvents() public method

Returns true if this collection contains any events.
public hasEvents ( ) : boolean
return boolean True if this collection contains any events.

invoke() public method

Invoke this object.
public invoke ( ) : mixed
return mixed The result of invocation.

invokeWith() public method

This method supports reference parameters.
public invokeWith ( Arguments | array $arguments = [] ) : mixed
$arguments Eloquent\Phony\Call\Arguments | array The arguments.
return mixed The result of invocation.

isAnonymous() public method

Returns true if anonymous.
public isAnonymous ( ) : boolean
return boolean True if anonymous.

iterated() public method

Throws an exception unless this spy returned an iterable.
public iterated ( ) : IterableVerifier
return Eloquent\Phony\Verification\IterableVerifier The result.

label() public method

Get the label.
public label ( ) : string | null
return string | null The label.

lastCall() public method

Get the last call.
public lastCall ( ) : Eloquent\Phony\Call\Call
return Eloquent\Phony\Call\Call The call.

lastEvent() public method

Get the last event.
public lastEvent ( ) : Eloquent\Phony\Event\Event
return Eloquent\Phony\Event\Event The event.

responded() public method

Throws an exception unless this spy responded.
public responded ( ) : Eloquent\Phony\Event\EventCollection
return Eloquent\Phony\Event\EventCollection The result.

returned() public method

Throws an exception unless this spy returned the supplied value.
public returned ( mixed $value = null ) : Eloquent\Phony\Event\EventCollection
$value mixed The value.
return Eloquent\Phony\Event\EventCollection The result.

setCalls() public method

Set the calls.
public setCalls ( array $calls )
$calls array

setLabel() public method

Set the label.
public setLabel ( string | null $label )
$label string | null The label.

setUseGeneratorSpies() public method

Turn on or off the use of generator spies.
public setUseGeneratorSpies ( boolean $useGeneratorSpies )
$useGeneratorSpies boolean True to use generator spies.

setUseIterableSpies() public method

Turn on or off the use of iterable spies.
public setUseIterableSpies ( boolean $useIterableSpies )
$useIterableSpies boolean True to use iterable spies.

spy() public method

Get the spy.
public spy ( ) : Eloquent\Phony\Spy\Spy
return Eloquent\Phony\Spy\Spy The spy.

startRecording() public method

Start recording calls.
public startRecording ( )

stopRecording() public method

Stop recording calls.
public stopRecording ( )

threw() public method

Throws an exception unless an exception of the supplied type was thrown.
public threw ( Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null $type = null ) : Eloquent\Phony\Event\EventCollection
$type Eloquent\Phony\Matcher\Matcher | Exceptio\Exception | Erro\Error | string | null An exception to match, the type of exception, or null for any exception.
return Eloquent\Phony\Event\EventCollection The result.

useGeneratorSpies() public method

Returns true if this spy uses generator spies.
public useGeneratorSpies ( ) : boolean
return boolean True if this spy uses generator spies.

useIterableSpies() public method

Returns true if this spy uses iterable spies.
public useIterableSpies ( ) : boolean
return boolean True if this spy uses iterable spies.