function TestKernel::setContainerWithKernel
Sets a container with a kernel service on the Drupal class.
Return value
\Drupal\Component\DependencyInjection\ContainerInterface A container with the kernel service set.
File
-
core/
lib/ Drupal/ Core/ Test/ TestKernel.php, line 33
Class
- TestKernel
- Kernel that is only used by mock front controllers.
Namespace
Drupal\Core\TestCode
public static function setContainerWithKernel() {
$container = new ContainerBuilder();
$kernel = new DrupalKernel('test', NULL);
// Objects of the same type will have access to each others private and
// protected members even though they are not the same instances. This is
// because the implementation specific details are already known when
// inside those objects.
$kernel->container = $container;
$container->set('kernel', $kernel);
$container->set(ReverseContainer::class, new ReverseContainer($container));
\Drupal::setContainer($container);
return $container;
}