3 namespace Drupal\Tests\system\Functional\ServiceProvider;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests service provider registration to the DIC.
10 * @group ServiceProvider
12 class ServiceProviderWebTest extends BrowserTestBase {
19 public static $modules = ['file', 'service_provider_test'];
22 * Tests that module service providers get registered to the DIC.
24 * Also tests that services provided by module service providers get
25 * registered to the DIC.
27 public function testServiceProviderRegistrationIntegration() {
28 $this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service has been registered to the DIC');
29 // The event subscriber method in the test class calls
30 // \Drupal\Core\Messenger\MessengerInterface::addStatus() with a message
31 // saying it has fired. This will fire on every page request so it should
32 // show up on the front page.
34 $this->assertText(t('The service_provider_test event subscriber fired!'), 'The service_provider_test event subscriber fired');