9 use PHPUnit\Framework\ExpectationFailedException;
10 use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
29 private $sequenceIndex;
34 private $currentIndex = -1;
39 private $indexes = [];
46 $this->sequenceIndex = $sequenceIndex;
54 return 'invoked at sequence index ' . $this->sequenceIndex;
61 public function matches(BaseInvocation $invocation): bool
64 if (!isset($this->indexes[$invocation->getMethodName()])) {
66 $this->indexes[$invocation->getMethodName()] = 0;
69 $this->indexes[$invocation->getMethodName()]++;
71 $this->currentIndex++;
74 return $this->indexes[$invocation->getMethodName()] == $this->sequenceIndex;
82 public function invoked(BaseInvocation $invocation)
94 if ($this->currentIndex < $this->sequenceIndex) {
95 throw new ExpectationFailedException(
97 'The expected invocation at index %s was never reached.',
__construct($sequenceIndex)
invoked(BaseInvocation $invocation)
matches(BaseInvocation $invocation)