DiscoverServiceProvidersTest.php in Drupal 9
File
core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php
View source
<?php
namespace Drupal\Tests\Core\DrupalKernel;
use Composer\Autoload\ClassLoader;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Drupal\Tests\UnitTestCase;
class DiscoverServiceProvidersTest extends UnitTestCase {
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));
}
public function testDiscoverServiceNoContainerYamls() {
new Settings([]);
$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' => [],
];
$this
->assertSame($expect, $reflected_yamls
->getValue($kernel));
}
}