protected function KernelTestBase::bootEnvironment in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::bootEnvironment()
Bootstraps a basic test environment.
Should not be called by tests. Only visible for DrupalKernel integration tests.
@internal
See also
\Drupal\system\Tests\DrupalKernel\DrupalKernelTest
1 call to KernelTestBase::bootEnvironment()
- KernelTestBase::setUp in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 234 - Contains \Drupal\KernelTests\KernelTestBase.
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
protected function bootEnvironment() {
$this->streamWrappers = array();
\Drupal::unsetContainer();
// @see /core/tests/bootstrap.php
$this->classLoader = $GLOBALS['loader'];
require_once $this->root . '/core/includes/bootstrap.inc';
// Set up virtual filesystem.
// Ensure that the generated test site directory does not exist already,
// which may happen with a large amount of concurrent threads and
// long-running tests.
do {
$suffix = mt_rand(100000, 999999);
$this->siteDirectory = 'sites/simpletest/' . $suffix;
$this->databasePrefix = 'simpletest' . $suffix;
} while (is_dir($this->root . '/' . $this->siteDirectory));
$this->vfsRoot = vfsStream::setup('root', NULL, array(
'sites' => array(
'simpletest' => array(
$suffix => array(),
),
),
));
$this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix);
mkdir($this->siteDirectory . '/files', 0775);
mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE);
// Ensure that all code that relies on drupal_valid_test_ua() can still be
// safely executed. This primarily affects the (test) site directory
// resolution (used by e.g. LocalStream and PhpStorage).
$this->databasePrefix = 'simpletest' . $suffix;
drupal_valid_test_ua($this->databasePrefix);
$settings = array(
'hash_salt' => get_class($this),
'file_public_path' => $this->siteDirectory . '/files',
// Disable Twig template caching/dumping.
'twig_cache' => FALSE,
);
new Settings($settings);
$GLOBALS['config_directories'] = array(
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
);
foreach (Database::getAllConnectionInfo() as $key => $targets) {
Database::removeConnection($key);
}
Database::addConnectionInfo('default', 'default', $this
->getDatabaseConnectionInfo()['default']);
}