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

Breadcrumb

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

function Matcher::invoked

Throws

Exception

ExpectationFailedException

MatchBuilderNotFoundException

MethodNameNotConfiguredException

RuntimeException

File

vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Matcher.php, line 89

Class

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

Namespace

PHPUnit\Framework\MockObject

Code

public function invoked(Invocation $invocation) : mixed {
    if ($this->methodNameRule === null) {
        throw new MethodNameNotConfiguredException();
    }
    if ($this->afterMatchBuilderId !== null) {
        $matcher = $invocation->object()
            ->__phpunit_getInvocationHandler()
            ->lookupMatcher($this->afterMatchBuilderId);
        if (!$matcher) {
            throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
        }
    }
    $this->invocationRule
        ->invoked($invocation);
    try {
        $this->parametersRule?->apply($invocation);
    } catch (ExpectationFailedException $e) {
        throw new ExpectationFailedException(sprintf("Expectation failed for %s when %s\n%s", $this->methodNameRule
            ->toString(), $this->invocationRule
            ->toString(), $e->getMessage()), $e->getComparisonFailure());
    }
    if ($this->stub) {
        return $this->stub
            ->invoke($invocation);
    }
    return $invocation->generateReturnValue();
}

API Navigation

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