5e86164f6e6dc2504bac02d91034315b4a9a0d17
[yaffs-website] / web / core / modules / system / tests / src / Functional / ServiceProvider / ServiceProviderWebTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\ServiceProvider;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests service provider registration to the DIC.
9  *
10  * @group ServiceProvider
11  */
12 class ServiceProviderWebTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['file', 'service_provider_test'];
20
21   /**
22    * Tests that module service providers get registered to the DIC.
23    *
24    * Also tests that services provided by module service providers get
25    * registered to the DIC.
26    */
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.
33     $this->drupalGet('');
34     $this->assertText(t('The service_provider_test event subscriber fired!'), 'The service_provider_test event subscriber fired');
35   }
36
37 }