public function ServicesDefaultsTest::testDefaultTags in Drupal 10
Tests that default tags for 'services_defaults_test.service' are applied.
File
- core/
tests/ Drupal/ KernelTests/ Core/ DependencyInjection/ ServicesDefaultsTest.php, line 51
Class
- ServicesDefaultsTest
- Tests services _defaults definition.
Namespace
Drupal\KernelTests\Core\DependencyInjectionCode
public function testDefaultTags() {
// Ensure default tags work.
$testServiceDefinition = $this->container
->getDefinition('Drupal\\services_defaults_test\\TestService');
$testInjection1Definition = $this->container
->getDefinition('Drupal\\services_defaults_test\\TestInjection');
$testInjection2Definition = $this->container
->getDefinition('Drupal\\services_defaults_test\\TestInjection2');
$this
->assertTrue($testServiceDefinition
->hasTag('foo.tag1'));
$this
->assertTrue($testServiceDefinition
->hasTag('bar.tag2'));
$this
->assertSame([
[
'test' => 123,
],
], $testServiceDefinition
->getTag('bar.tag2'));
$this
->assertTrue($testServiceDefinition
->hasTag('bar.tag3'));
$this
->assertSame([
[
'value' => NULL,
],
], $testServiceDefinition
->getTag('bar.tag3'));
$this
->assertSame($testServiceDefinition
->getTags(), $testInjection1Definition
->getTags());
// Ensure overridden tag works.
$this
->assertTrue($testInjection2Definition
->hasTag('zee.bang'));
$this
->assertTrue($testInjection2Definition
->hasTag('foo.tag1'));
$this
->assertTrue($testInjection2Definition
->hasTag('bar.tag2'));
$this
->assertSame([
[
'test' => 321,
],
[
'test' => 123,
],
], $testInjection2Definition
->getTag('bar.tag2'));
$this
->assertTrue($testInjection2Definition
->hasTag('bar.tag3'));
$this
->assertSame([
[
'value' => NULL,
],
], $testInjection2Definition
->getTag('bar.tag3'));
}