Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/src/Matcher/InvokedAtLeastCount.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 | |
16 * N times. | |
17 */ | |
18 class InvokedAtLeastCount extends InvokedRecorder | |
19 { | |
20 /** | |
21 * @var int | |
22 */ | |
23 private $requiredInvocations; | |
24 | |
25 /** | |
26 * @param int $requiredInvocations | |
27 */ | |
28 public function __construct($requiredInvocations) | |
29 { | |
30 $this->requiredInvocations = $requiredInvocations; | |
31 } | |
32 | |
33 /** | |
34 * @return string | |
35 */ | |
36 public function toString() | |
37 { | |
38 return 'invoked at least ' . $this->requiredInvocations . ' times'; | |
39 } | |
40 | |
41 /** | |
42 * Verifies that the current expectation is valid. If everything is OK the | |
43 * code should just return, if not it must throw an exception. | |
44 * | |
45 * @throws ExpectationFailedException | |
46 */ | |
47 public function verify() | |
48 { | |
49 $count = $this->getInvocationCount(); | |
50 | |
51 if ($count < $this->requiredInvocations) { | |
52 throw new ExpectationFailedException( | |
53 'Expected invocation at least ' . $this->requiredInvocations . | |
54 ' times but it occurred ' . $count . ' time(s).' | |
55 ); | |
56 } | |
57 } | |
58 } |