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

Breadcrumb

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

function TestCase::createStub

Creates a test stub for the specified interface or class.

@psalm-template RealInstanceType of object

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

@psalm-return Stub&RealInstanceType

Throws

InvalidArgumentException

MockObjectException

NoPreviousThrowableException

1 call to TestCase::createStub()
TestCase::createConfiguredStub in vendor/phpunit/phpunit/src/Framework/TestCase.php
Creates (and configures) a test stub for the specified interface or class.

File

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

Class

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

Namespace

PHPUnit\Framework

Code

protected static function createStub(string $originalClassName) : Stub {
    $stub = (new MockGenerator())->testDouble($originalClassName, true, callOriginalConstructor: false, callOriginalClone: false, cloneArguments: false, allowMockingUnknownTypes: false);
    Event\Facade::emitter()->testCreatedStub($originalClassName);
    assert($stub instanceof $originalClassName);
    assert($stub instanceof Stub);
    return $stub;
}
RSS feed
Powered by Drupal