public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) { parent::invoked($invocation); $count = $this->getInvocationCount(); if ($count > $this->expectedCount) { throw new PHPUnit_Framework_ExpectationFailedException(sprintf('Expected count for invocation <%s> is wrong.', $invocation->toString()), new PHPUnit_Framework_ComparisonFailure_Scalar($this->expectedCount, $count)); } }
/** * @param PHPUnit_Framework_MockObject_Invocation $invocation * @throws PHPUnit_Framework_ExpectationFailedException */ public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) { parent::invoked($invocation); $count = $this->getInvocationCount(); if ($count > $this->expectedCount) { $message = $invocation->toString() . ' '; switch ($this->expectedCount) { case 0: $message .= 'was not expected to be called.'; break; case 1: $message .= 'was not expected to be called more than once.'; break; default: $message .= sprintf('was not expected to be called more than %d times.', $this->expectedCount); } throw new PHPUnit_Framework_ExpectationFailedException($message); } }