function DrupalKernelTest::testBuildParametersRemoved
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::testBuildParametersRemoved()
Tests that dot-prefixed build parameters are removed from the container.
Build parameters (e.g. '.hook_data') are used to pass data between compiler passes. RemoveBuildParametersPass strips them so they don't bloat the cached container definition with data that is only needed at build time.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php, line 173
Class
- DrupalKernelTest
- Tests DIC compilation to disk.
Namespace
Drupal\KernelTests\Core\DrupalKernelCode
public function testBuildParametersRemoved() : void {
$request = Request::createFromGlobals();
$kernel = $this->getTestKernel($request);
$container = $kernel->getContainer();
$build_only = array_filter(array_keys($container->getParameterBag()
->all()), fn(string $name) => str_starts_with($name, '.'));
$this->assertEmpty($build_only, sprintf('Dot-prefixed build parameters should not be in the compiled container, but found: %s', implode(', ', $build_only)));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.