annotate vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2 /*
Chris@0 3 * This file is part of the PHPUnit_MockObject package.
Chris@0 4 *
Chris@0 5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
Chris@0 6 *
Chris@0 7 * For the full copyright and license information, please view the LICENSE
Chris@0 8 * file that was distributed with this source code.
Chris@0 9 */
Chris@0 10
Chris@0 11 /**
Chris@0 12 * Invocation matcher which checks if a method has been invoked at least one
Chris@0 13 * time.
Chris@0 14 *
Chris@0 15 * If the number of invocations is 0 it will throw an exception in verify.
Chris@0 16 *
Chris@0 17 * @since Class available since Release 1.0.0
Chris@0 18 */
Chris@0 19 class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
Chris@0 20 {
Chris@0 21 /**
Chris@0 22 * @return string
Chris@0 23 */
Chris@0 24 public function toString()
Chris@0 25 {
Chris@0 26 return 'invoked at least once';
Chris@0 27 }
Chris@0 28
Chris@0 29 /**
Chris@0 30 * Verifies that the current expectation is valid. If everything is OK the
Chris@0 31 * code should just return, if not it must throw an exception.
Chris@0 32 *
Chris@0 33 * @throws PHPUnit_Framework_ExpectationFailedException
Chris@0 34 */
Chris@0 35 public function verify()
Chris@0 36 {
Chris@0 37 $count = $this->getInvocationCount();
Chris@0 38
Chris@0 39 if ($count < 1) {
Chris@0 40 throw new PHPUnit_Framework_ExpectationFailedException(
Chris@0 41 'Expected invocation at least once but it never occured.'
Chris@0 42 );
Chris@0 43 }
Chris@0 44 }
Chris@0 45 }