Skip to content

ConflictingExpectation ​

Rasuvaeff\Understudy\Exception\ConflictingExpectation

Class — Package: rasuvaeff/understudy — Source — Version: v1.1.0-1-g6ed023f

Extends: LogicException

Implements: Throwable, Stringable, Exception\UnderstudyError

A when() or expect() names a call another registration already specifies, and the two would not compose: whichever is declared later takes the dispatch, and the earlier one silently loses its purpose — a stub's answer is replaced by the mode default, or a count is starved and reported as "called never" about a call that did happen.

Refused at registration, because that is where the mistake is made: the dispatch semantics stay exactly as documented, and the only layering this closes is the one with no working reading. Two plain stubs for one call are still the documented "most recently registered wins" arrangement.

Methods ​

claimAfterStub() ​

php
static claimAfterStub(non-empty-string $label, non-empty-string $spec): self

Builds the error for a claim registered after an identical stub.

stubAfterCountedExpectation() ​

php
static stubAfterCountedExpectation(
    non-empty-string $label,
    non-empty-string $spec,
): self

Builds the error for a stub registered after a counted expectation.

duplicateCountedExpectation() ​

php
static duplicateCountedExpectation(
    non-empty-string $label,
    non-empty-string $spec,
): self

Builds the error for duplicate counted expectations.