public function ServiceDestructionTest::testDestructionUnused in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/DrupalKernel/ServiceDestructionTest.php \Drupal\system\Tests\DrupalKernel\ServiceDestructionTest::testDestructionUnused()
Verifies that services are not unnecessarily destructed when not used.
File
- core/
modules/ system/ src/ Tests/ DrupalKernel/ ServiceDestructionTest.php, line 45 - Contains \Drupal\system\Tests\DrupalKernel\ServiceDestructionTest.
Class
- ServiceDestructionTest
- Tests that services are correctly destructed.
Namespace
Drupal\system\Tests\DrupalKernelCode
public function testDestructionUnused() {
// Enable the test module to add it to the container.
$this
->enableModules(array(
'service_provider_test',
));
$request = $this->container
->get('request_stack')
->getCurrentRequest();
$kernel = $this->container
->get('kernel');
$kernel
->preHandle($request);
// The service has not been destructed yet.
$this
->assertNull(\Drupal::state()
->get('service_provider_test.destructed'));
// Terminate the kernel. The test class has not been called, so it should not
// be destructed.
$response = new Response();
$kernel
->terminate($request, $response);
$this
->assertNull(\Drupal::state()
->get('service_provider_test.destructed'));
}