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

Breadcrumb

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

function TestCase::getMockForTrait

Creates a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the `$mockedMethods` parameter.

@psalm-param trait-string $traitName

Throws

InvalidArgumentException

MockObjectException

Deprecated

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

File

vendor/phpunit/phpunit/src/Framework/TestCase.php, line 1511

Class

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

Namespace

PHPUnit\Framework

Code

protected function getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false) : MockObject {
    $mockObject = (new MockGenerator())->mockObjectForTrait($traitName, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $mockedMethods, $cloneArguments);
    $this->registerMockObject($mockObject);
    Event\Facade::emitter()->testCreatedMockObjectForTrait($traitName);
    return $mockObject;
}

API Navigation

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