function PhpExtensionsValidator::insideTest

Whether this validator is running inside a test.

Return value

bool

1 call to PhpExtensionsValidator::insideTest()
PhpExtensionsValidator::isExtensionLoaded in core/modules/package_manager/src/Validator/PhpExtensionsValidator.php
Indicates if a particular PHP extension is loaded.

File

core/modules/package_manager/src/Validator/PhpExtensionsValidator.php, line 84

Class

PhpExtensionsValidator
Performs validation if certain PHP extensions are enabled.

Namespace

Drupal\package_manager\Validator

Code

private static function insideTest() : bool {
    // @see \Drupal\Core\CoreServiceProvider::registerTest()
    $in_functional_test = drupal_valid_test_ua();
    // @see \Drupal\Core\DependencyInjection\DependencySerializationTrait::__wakeup()
    $in_kernel_test = isset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
    // @see \Drupal\BuildTests\Framework\BuildTestBase::setUp()
    $in_build_test = str_contains(__FILE__, DrupalFilesystem::getOsTemporaryDirectory() . '/build_workspace_');
    return $in_functional_test || $in_kernel_test || $in_build_test;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.