summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
blob: 73d6910087dfcf4824fa5de0eb1da376d8f5ddb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Drupal\Tests\system\Functional\ServiceProvider;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests service provider registration to the DIC.
 *
 * @group ServiceProvider
 */
class ServiceProviderWebTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = ['file', 'service_provider_test'];

  /**
   * Tests that module service providers get registered to the DIC.
   *
   * Also tests that services provided by module service providers get
   * registered to the DIC.
   */
  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');
  }

}