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\ExtensionCode
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);
}