public function KernelTestBaseTest::testRegister in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRegister()
- 9 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRegister()
@covers ::register
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBaseTest.php, line 116
Class
- KernelTestBaseTest
- @coversDefaultClass \Drupal\KernelTests\KernelTestBase
Namespace
Drupal\KernelTestsCode
public function testRegister() {
// Verify that this container is identical to the actual container.
$this
->assertInstanceOf('Symfony\\Component\\DependencyInjection\\ContainerInterface', $this->container);
$this
->assertSame($this->container, \Drupal::getContainer());
// The request service should never exist.
$this
->assertFalse($this->container
->has('request'));
// Verify that there is a request stack.
$request = $this->container
->get('request_stack')
->getCurrentRequest();
$this
->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $request);
$this
->assertSame($request, \Drupal::request());
// Trigger a container rebuild.
$this
->enableModules([
'system',
]);
// Verify that this container is identical to the actual container.
$this
->assertInstanceOf('Symfony\\Component\\DependencyInjection\\ContainerInterface', $this->container);
$this
->assertSame($this->container, \Drupal::getContainer());
// The request service should never exist.
$this
->assertFalse($this->container
->has('request'));
// Verify that there is a request stack (and that it persisted).
$new_request = $this->container
->get('request_stack')
->getCurrentRequest();
$this
->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $new_request);
$this
->assertSame($new_request, \Drupal::request());
$this
->assertSame($request, $new_request);
// Ensure getting the router.route_provider does not trigger a deprecation
// message that errors.
$this->container
->get('router.route_provider');
}