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

Breadcrumb

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

function ExtensionBootstrapper::bootstrap

@psalm-param class-string $className @psalm-param array<string, string> $parameters

File

vendor/phpunit/phpunit/src/Runner/Extension/ExtensionBootstrapper.php, line 43

Class

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

Namespace

PHPUnit\Runner\Extension

Code

public function bootstrap(string $className, array $parameters) : void {
    if (!class_exists($className)) {
        EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Cannot bootstrap extension because class %s does not exist', $className));
        return;
    }
    if (!in_array(Extension::class, class_implements($className), true)) {
        EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Cannot bootstrap extension because class %s does not implement interface %s', $className, Extension::class));
        return;
    }
    try {
        $instance = (new ReflectionClass($className))->newInstance();
        assert($instance instanceof Extension);
        $instance->bootstrap($this->configuration, $this->facade, ParameterCollection::fromArray($parameters));
    } catch (Throwable $t) {
        EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Bootstrapping of extension %s failed: %s%s%s', $className, $t->getMessage(), PHP_EOL, $t->getTraceAsString()));
        return;
    }
    EventFacade::emitter()->testRunnerBootstrappedExtension($className, $parameters);
}

API Navigation

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