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 one Chris@0: * time. Chris@0: * Chris@0: * If the number of invocations is 0 it will throw an exception in verify. Chris@0: * Chris@0: * @since Class available since Release 1.0.0 Chris@0: */ Chris@0: class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder Chris@0: { Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function toString() Chris@0: { Chris@0: return 'invoked at least once'; 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 < 1) { Chris@0: throw new PHPUnit_Framework_ExpectationFailedException( Chris@0: 'Expected invocation at least once but it never occured.' Chris@0: ); Chris@0: } Chris@0: } Chris@0: }