function DrupalKernelTest::getTestKernel
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::getTestKernel()
- 10 core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::getTestKernel()
- 11.x core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\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.
3 calls to DrupalKernelTest::getTestKernel()
- DrupalKernelTest::testCompileDIC in core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php - Tests DIC compilation.
- DrupalKernelTest::testKernelEvent in core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php - Tests KernelEvent class_alias() override.
- DrupalKernelTest::testPreventChangeOfSitePath in core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php - Tests setting of site path after kernel boot.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php, line 48
Class
- DrupalKernelTest
- Tests DIC compilation to disk.
Namespace
Drupal\KernelTests\Core\DrupalKernelCode
protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
// Manually create kernel to avoid replacing settings.
$class_loader = (require $this->root . '/autoload.php');
$kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing');
$this->setSetting('container_yamls', []);
$this->setSetting('hash_salt', $this->databasePrefix);
if (isset($modules_enabled)) {
$kernel->updateModules($modules_enabled);
}
$kernel->boot();
return $kernel;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.