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

Breadcrumb

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

function TestCase::createMock

Creates a mock object for the specified interface or class.

@psalm-template RealInstanceType of object

@psalm-param class-string<RealInstanceType> $originalClassName

@psalm-return MockObject&RealInstanceType

Throws

InvalidArgumentException

MockObjectException

NoPreviousThrowableException

6 calls to TestCase::createMock()
CompoundConstraintTestCase::createContext in vendor/symfony/validator/Test/CompoundConstraintTestCase.php
ConstraintValidatorTestCase::createContext in vendor/symfony/validator/Test/ConstraintValidatorTestCase.php
TestCase::createConfiguredMock in vendor/phpunit/phpunit/src/Framework/TestCase.php
Creates (and configures) a mock object for the specified interface or class.
TransportFactoryTestCase::getClient in vendor/symfony/mailer/Test/TransportFactoryTestCase.php
TransportFactoryTestCase::getDispatcher in vendor/symfony/mailer/Test/TransportFactoryTestCase.php

... See full list

File

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

Class

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

Namespace

PHPUnit\Framework

Code

protected function createMock(string $originalClassName) : MockObject {
    $mock = (new MockGenerator())->testDouble($originalClassName, true, callOriginalConstructor: false, callOriginalClone: false, cloneArguments: false, allowMockingUnknownTypes: false);
    assert($mock instanceof $originalClassName);
    assert($mock instanceof MockObject);
    $this->registerMockObject($mock);
    Event\Facade::emitter()->testCreatedMockObject($originalClassName);
    return $mock;
}
RSS feed
Powered by Drupal