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 looks for a specific method name in the invocations. Chris@0: * Chris@0: * Checks the method name all incoming invocations, the name is checked against Chris@0: * the defined constraint $constraint. If the constraint is met it will return Chris@0: * true in matches(). Chris@0: * Chris@0: * @since Class available since Release 1.0.0 Chris@0: */ Chris@0: class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation Chris@0: { Chris@0: /** Chris@0: * @var PHPUnit_Framework_Constraint Chris@0: */ Chris@0: protected $constraint; Chris@0: Chris@0: /** Chris@0: * @param PHPUnit_Framework_Constraint|string Chris@0: * @throws PHPUnit_Framework_Constraint Chris@0: */ Chris@0: public function __construct($constraint) Chris@0: { Chris@0: if (!$constraint instanceof PHPUnit_Framework_Constraint) { Chris@0: if (!is_string($constraint)) { Chris@0: throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); Chris@0: } Chris@0: Chris@0: $constraint = new PHPUnit_Framework_Constraint_IsEqual( Chris@0: $constraint, Chris@0: 0, Chris@0: 10, Chris@0: false, Chris@0: true Chris@0: ); Chris@0: } Chris@0: Chris@0: $this->constraint = $constraint; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function toString() Chris@0: { Chris@0: return 'method name ' . $this->constraint->toString(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param PHPUnit_Framework_MockObject_Invocation $invocation Chris@0: * @return bool Chris@0: */ Chris@0: public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) Chris@0: { Chris@0: return $this->constraint->evaluate($invocation->methodName, '', true); Chris@0: } Chris@0: }