You are here

class PHPUnit_Framework_MockObject_Matcher_MethodName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php \PHPUnit_Framework_MockObject_Matcher_MethodName

Invocation matcher which looks for a specific method name in the invocations.

Checks the method name all incoming invocations, the name is checked against the defined constraint $constraint. If the constraint is met it will return true in matches().

@since Class available since Release 1.0.0

Hierarchy

Expanded class hierarchy of PHPUnit_Framework_MockObject_Matcher_MethodName

File

vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php, line 20

View source
class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation {

  /**
   * @var PHPUnit_Framework_Constraint
   */
  protected $constraint;

  /**
   * @param  PHPUnit_Framework_Constraint|string
   * @throws PHPUnit_Framework_Constraint
   */
  public function __construct($constraint) {
    if (!$constraint instanceof PHPUnit_Framework_Constraint) {
      if (!is_string($constraint)) {
        throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
      }
      $constraint = new PHPUnit_Framework_Constraint_IsEqual($constraint, 0, 10, false, true);
    }
    $this->constraint = $constraint;
  }

  /**
   * @return string
   */
  public function toString() {
    return 'method name ' . $this->constraint
      ->toString();
  }

  /**
   * @param  PHPUnit_Framework_MockObject_Invocation $invocation
   * @return bool
   */
  public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) {
    return $this->constraint
      ->evaluate($invocation->methodName, '', true);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PHPUnit_Framework_MockObject_Matcher_MethodName::$constraint protected property
PHPUnit_Framework_MockObject_Matcher_MethodName::matches public function Overrides PHPUnit_Framework_MockObject_Matcher_Invocation::matches
PHPUnit_Framework_MockObject_Matcher_MethodName::toString public function Overrides PHPUnit_Framework_SelfDescribing::toString
PHPUnit_Framework_MockObject_Matcher_MethodName::__construct public function
PHPUnit_Framework_MockObject_Matcher_StatelessInvocation::invoked public function Registers the invocation $invocation in the object as being invoked. This will only occur after matches() returns true which means the current invocation is the correct one. Overrides PHPUnit_Framework_MockObject_Matcher_Invocation::invoked
PHPUnit_Framework_MockObject_Matcher_StatelessInvocation::verify public function Checks if the invocation $invocation matches the current rules. If it does the matcher will get the invoked() method called which should check if an expectation is met. Overrides PHPUnit_Framework_MockObject_Verifiable::verify 2