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

Breadcrumb

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

function MockBuilder::addMethods

Specifies methods that don't exist in the class which you want to mock.

@psalm-param list<non-empty-string> $methods

Return value

$this

Throws

CannotUseAddMethodsException

ReflectionException

RuntimeException

Deprecated

https://github.com/sebastianbergmann/phpunit/issues/5320

File

vendor/phpunit/phpunit/src/Framework/MockObject/MockBuilder.php, line 238

Class

MockBuilder
@psalm-template MockedType

Namespace

PHPUnit\Framework\MockObject

Code

public function addMethods(array $methods) : self {
    if (empty($methods)) {
        $this->emptyMethodsArray = true;
        return $this;
    }
    try {
        $reflector = new ReflectionClass($this->type);
        // @codeCoverageIgnoreStart
    } catch (\ReflectionException $e) {
        throw new ReflectionException($e->getMessage(), $e->getCode(), $e);
        // @codeCoverageIgnoreEnd
    }
    foreach ($methods as $method) {
        if ($reflector->hasMethod($method)) {
            throw new CannotUseAddMethodsException($this->type, $method);
        }
    }
    $this->methods = array_merge($this->methods, $methods);
    return $this;
}

API Navigation

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