Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InvocationMocker.php

function InvocationMocker::method

Return value

$this

Throws

InvalidArgumentException

MethodCannotBeConfiguredException

MethodNameAlreadyConfiguredException

Overrides MethodNameMatch::method

File

vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Builder/InvocationMocker.php, line 249

Class

InvocationMocker
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework\MockObject\Builder

Code

public function method(Constraint|string $constraint) : self {
    if ($this->matcher
        ->hasMethodNameRule()) {
        throw new MethodNameAlreadyConfiguredException();
    }
    if (is_string($constraint)) {
        $this->configurableMethodNames ??= array_flip(array_map(static fn(ConfigurableMethod $configurable) => strtolower($configurable->name()), $this->configurableMethods));
        if (!array_key_exists(strtolower($constraint), $this->configurableMethodNames)) {
            throw new MethodCannotBeConfiguredException($constraint);
        }
    }
    $this->matcher
        ->setMethodNameRule(new Rule\MethodName($constraint));
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal