Skip to content

VerificationFailure

Rasuvaeff\Understudy\VerificationFailure

ClassPackage: rasuvaeff/understudySourceVersion: v0.4.1

The structured half of one verification failure — the same facts the rendered message states, addressable by field.

For tooling that wants to do something with a failure other than print it: a runner adapter, an IDE plugin, a report aggregator. The rendered message stays the human surface; this class is the machine one.

Which fields are set depends on the kind:

KinddoubleexpectationexpectedMinimum/expectedMaximumactualCountobservedCallsexpectedCalls
UnmetExpectationlabelcall specthe claimed boundsmatched callscalls to the same method
StrictStubUnusedlabelcall spec0
OutOfOrderlabelthe call that came first
OutOfSequencethe mismatched positioncalls madethe whole protocolthe specified sequence
UnaccountedCallslabelunaccounted callsthe unaccounted calls
UnusedDoublelabel0/0calls receivedevery call

The readonly fields of this class, of FailureKind, and of the exceptions carrying them are frozen public API from v0.1.0: renaming, removing or retyping any of them is a major-version change. New kinds and newly-populated fields are additive and may arrive in a minor.

Constructor

php
__construct(
    FailureKind $kind,
    non-empty-string $summary,
    string|null $double = NULL,
    string|null $expectation = NULL,
    int<0, max>|null $expectedMinimum = NULL,
    int<0, max>|null $expectedMaximum = NULL,
    int<0, max>|null $actualCount = NULL,
    list<\Invocation>|null $observedCalls = NULL,
    list<string>|null $expectedCalls = NULL,
)
ParameterTypeDefaultDescription
$kindFailureKindrequired
$summarynon-empty-stringrequiredthis failure's rendered text; the exception's message is these joined with a blank line
$doublestring|nullNULLthe label of the double the claim is about
$expectationstring|nullNULLthe call specification, as failure messages render it
$expectedMinimumint<0, max>|nullNULL
$expectedMaximumint<0, max>|nullNULL
$actualCountint<0, max>|nullNULL
$observedCallslist<\Invocation>|nullNULLthe calls the rendered report shows
$expectedCallslist<string>|nullNULLthe specified sequence, for OutOfSequence