Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: /** Chris@0: * Invocation matcher which checks if a method has been invoked at least Chris@0: * N times. Chris@0: * Chris@0: * @since Class available since Release 2.2.0 Chris@0: */ Chris@0: class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder Chris@0: { Chris@0: /** Chris@0: * @var int Chris@0: */ Chris@0: private $requiredInvocations; Chris@0: Chris@0: /** Chris@0: * @param int $requiredInvocations Chris@0: */ Chris@0: public function __construct($requiredInvocations) Chris@0: { Chris@0: $this->requiredInvocations = $requiredInvocations; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function toString() Chris@0: { Chris@0: return 'invoked at least ' . $this->requiredInvocations . ' times'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Verifies that the current expectation is valid. If everything is OK the Chris@0: * code should just return, if not it must throw an exception. Chris@0: * Chris@0: * @throws PHPUnit_Framework_ExpectationFailedException Chris@0: */ Chris@0: public function verify() Chris@0: { Chris@0: $count = $this->getInvocationCount(); Chris@0: Chris@0: if ($count < $this->requiredInvocations) { Chris@0: throw new PHPUnit_Framework_ExpectationFailedException( Chris@0: 'Expected invocation at least ' . $this->requiredInvocations . Chris@0: ' times but it occured ' . $count . ' time(s).' Chris@0: ); Chris@0: } Chris@0: } Chris@0: }