3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Invocation matcher which checks if a method has been invoked at least
15 * @since Class available since Release 2.2.0
17 class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
22 private $requiredInvocations;
25 * @param int $requiredInvocations
27 public function __construct($requiredInvocations)
29 $this->requiredInvocations = $requiredInvocations;
35 public function toString()
37 return 'invoked at least ' . $this->requiredInvocations . ' times';
41 * Verifies that the current expectation is valid. If everything is OK the
42 * code should just return, if not it must throw an exception.
44 * @throws PHPUnit_Framework_ExpectationFailedException
46 public function verify()
48 $count = $this->getInvocationCount();
50 if ($count < $this->requiredInvocations) {
51 throw new PHPUnit_Framework_ExpectationFailedException(
52 'Expected invocation at least ' . $this->requiredInvocations .
53 ' times but it occured ' . $count . ' time(s).'