public function ServiceProviderWebTest::testServiceProviderRegistrationIntegration in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php \Drupal\Tests\system\Functional\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/ tests/ src/ Functional/ ServiceProvider/ ServiceProviderWebTest.php, line 32
Class
- ServiceProviderWebTest
- Tests service provider registration to the DIC.
Namespace
Drupal\Tests\system\Functional\ServiceProviderCode
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\Core\Messenger\MessengerInterface::addStatus() 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
->assertSession()
->pageTextContains('The service_provider_test event subscriber fired!');
}