Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/src/Matcher/InvokedAtLeastOnce.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the phpunit-mock-objects package. | |
4 * | |
5 * (c) Sebastian Bergmann <sebastian@phpunit.de> | |
6 * | |
7 * For the full copyright and license information, please view the LICENSE | |
8 * file that was distributed with this source code. | |
9 */ | |
10 namespace PHPUnit\Framework\MockObject\Matcher; | |
11 | |
12 use PHPUnit\Framework\ExpectationFailedException; | |
13 | |
14 /** | |
15 * Invocation matcher which checks if a method has been invoked at least one | |
16 * time. | |
17 * | |
18 * If the number of invocations is 0 it will throw an exception in verify. | |
19 */ | |
20 class InvokedAtLeastOnce extends InvokedRecorder | |
21 { | |
22 /** | |
23 * @return string | |
24 */ | |
25 public function toString() | |
26 { | |
27 return 'invoked at least once'; | |
28 } | |
29 | |
30 /** | |
31 * Verifies that the current expectation is valid. If everything is OK the | |
32 * code should just return, if not it must throw an exception. | |
33 * | |
34 * @throws ExpectationFailedException | |
35 */ | |
36 public function verify() | |
37 { | |
38 $count = $this->getInvocationCount(); | |
39 | |
40 if ($count < 1) { | |
41 throw new ExpectationFailedException( | |
42 'Expected invocation at least once but it never occurred.' | |
43 ); | |
44 } | |
45 } | |
46 } |