Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the PHPUnit_MockObject 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 | |
11 /** | |
12 * Invocation matcher which looks for a specific method name in the invocations. | |
13 * | |
14 * Checks the method name all incoming invocations, the name is checked against | |
15 * the defined constraint $constraint. If the constraint is met it will return | |
16 * true in matches(). | |
17 * | |
18 * @since Class available since Release 1.0.0 | |
19 */ | |
20 class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation | |
21 { | |
22 /** | |
23 * @var PHPUnit_Framework_Constraint | |
24 */ | |
25 protected $constraint; | |
26 | |
27 /** | |
28 * @param PHPUnit_Framework_Constraint|string | |
29 * @throws PHPUnit_Framework_Constraint | |
30 */ | |
31 public function __construct($constraint) | |
32 { | |
33 if (!$constraint instanceof PHPUnit_Framework_Constraint) { | |
34 if (!is_string($constraint)) { | |
35 throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); | |
36 } | |
37 | |
38 $constraint = new PHPUnit_Framework_Constraint_IsEqual( | |
39 $constraint, | |
40 0, | |
41 10, | |
42 false, | |
43 true | |
44 ); | |
45 } | |
46 | |
47 $this->constraint = $constraint; | |
48 } | |
49 | |
50 /** | |
51 * @return string | |
52 */ | |
53 public function toString() | |
54 { | |
55 return 'method name ' . $this->constraint->toString(); | |
56 } | |
57 | |
58 /** | |
59 * @param PHPUnit_Framework_MockObject_Invocation $invocation | |
60 * @return bool | |
61 */ | |
62 public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) | |
63 { | |
64 return $this->constraint->evaluate($invocation->methodName, '', true); | |
65 } | |
66 } |