function DiscoverServiceProvidersTest::testDiscoverServiceCustom

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php \Drupal\Tests\Core\DrupalKernel\DiscoverServiceProvidersTest::testDiscoverServiceCustom()
  2. 10 core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php \Drupal\Tests\Core\DrupalKernel\DiscoverServiceProvidersTest::testDiscoverServiceCustom()
  3. 11.x core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php \Drupal\Tests\Core\DrupalKernel\DiscoverServiceProvidersTest::testDiscoverServiceCustom()

Tests discovery with user defined container yaml.

@covers ::discoverServiceProviders

File

core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php, line 21

Class

DiscoverServiceProvidersTest
@coversDefaultClass \Drupal\Core\DrupalKernel @group DrupalKernel

Namespace

Drupal\Tests\Core\DrupalKernel

Code

public function testDiscoverServiceCustom() {
    new Settings([
        'container_yamls' => [
            __DIR__ . '/fixtures/custom.yml',
        ],
    ]);
    $kernel = new DrupalKernel('prod', new ClassLoader());
    $kernel->discoverServiceProviders();
    $reflected_yamls = (new \ReflectionObject($kernel))->getProperty('serviceYamls');
    $reflected_yamls->setAccessible(TRUE);
    $expect = [
        'app' => [
            'core' => 'core/core.services.yml',
        ],
        'site' => [
            __DIR__ . '/fixtures/custom.yml',
        ],
    ];
    $this->assertSame($expect, $reflected_yamls->getValue($kernel));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.