You are here

public function ServiceProviderWebTest::testServiceProviderRegistrationIntegration in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php \Drupal\system\Tests\ServiceProvider\ServiceProviderWebTest::testServiceProviderRegistrationIntegration()

Tests that module service providers get registered to the DIC.

Also tests that services provided by module service providers get registered to the DIC.

File

core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php, line 32
Contains \Drupal\system\Tests\ServiceProvider\ServiceProviderWebTest.

Class

ServiceProviderWebTest
Tests service provider registration to the DIC.

Namespace

Drupal\system\Tests\ServiceProvider

Code

public function testServiceProviderRegistrationIntegration() {
  $this
    ->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service has been registered to the DIC');

  // The event subscriber method in the test class calls drupal_set_message()
  // with a message saying it has fired. This will fire on every page request
  // so it should show up on the front page.
  $this
    ->drupalGet('');
  $this
    ->assertText(t('The service_provider_test event subscriber fired!'), 'The service_provider_test event subscriber fired');
}