protected function DrupalKernelTest::getTestKernel in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php \Drupal\system\Tests\DrupalKernel\DrupalKernelTest::getTestKernel()
Build a kernel for testings.
Because the bootstrap is in DrupalKernel::boot and that involved loading settings from the filesystem we need to go to extra lengths to build a kernel for testing.
Parameters
\Symfony\Component\HttpFoundation\Request $request: A request object to use in booting the kernel.
array $modules_enabled: A list of modules to enable on the kernel.
Return value
\Drupal\Core\DrupalKernel New kernel for testing.
2 calls to DrupalKernelTest::getTestKernel()
- DrupalKernelTest::testCompileDIC in core/
modules/ system/ src/ Tests/ DrupalKernel/ DrupalKernelTest.php - Tests DIC compilation.
- DrupalKernelTest::testPreventChangeOfSitePath in core/
modules/ system/ src/ Tests/ DrupalKernel/ DrupalKernelTest.php - Tests setting of site path after kernel boot.
File
- core/
modules/ system/ src/ Tests/ DrupalKernel/ DrupalKernelTest.php, line 62 - Contains \Drupal\system\Tests\DrupalKernel\DrupalKernelTest.
Class
- DrupalKernelTest
- Tests DIC compilation to disk.
Namespace
Drupal\system\Tests\DrupalKernelCode
protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
// Manually create kernel to avoid replacing settings.
$class_loader = (require DRUPAL_ROOT . '/autoload.php');
$kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing');
$this
->settingsSet('container_yamls', []);
$this
->settingsSet('hash_salt', $this->databasePrefix);
if (isset($modules_enabled)) {
$kernel
->updateModules($modules_enabled);
}
$kernel
->boot();
return $kernel;
}