/** * @param \Kodova\Poser\Invocation\Invocation $wanted * @param \Kodova\Poser\Invocation\InvocationContainer $invocationContainer * @throws TimesException */ public function verify(Invocation $wanted, InvocationContainer $invocationContainer) { $invocations = $invocationContainer->getInvocations(function (Invocation $invocation) use($wanted) { if ($invocation->wasStubbed()) { return false; } return $wanted->matches($invocation); }); $actual = sizeof($invocations); if ($this->wantedCount == 0 && $actual > 0) { throw new TimesException($this->wantedCount, $invocations); } elseif ($this->wantedCount < $actual) { throw new TimesException($this->wantedCount, $invocations); } elseif ($this->wantedCount > $actual) { throw new TimesException($this->wantedCount, $invocations); } }
public function matches(Matchable $invocation) { return $this->invocation->matches($invocation); }
/** * @param \Kodova\Poser\Invocation\Answer $answer * @return Stubbable|void */ public function thenAnswer(Answer $answer) { $this->invocation->markStubbed(); $this->stub->addAnswer($answer); $this->invocationContainer->addStub($this->stub); }