diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index 05c6eef5dd..311d75b764 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -96,6 +96,7 @@ public function register($id, $class = null) { */ public function setAlias($alias, $id) { $alias = parent::setAlias($alias, $id); + // As of Symfony 3.4 all aliases are private by default. $alias->setPublic(TRUE); return $alias; } diff --git a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php index 80c8cedda9..baafcd594b 100644 --- a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php +++ b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php @@ -23,7 +23,6 @@ * @see https://github.com/symfony/symfony/pull/12521 * * @group EventDispatcher - * @group legacy */ class ContainerAwareEventDispatcherTest extends SymfonyContainerAwareEventDispatcherTest { @@ -196,6 +195,7 @@ public function testGetListenerPriorityWithServices() /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testAddAListenerService() { parent::testAddAListenerService(); @@ -203,6 +203,7 @@ public function testAddAListenerService() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testPreventDuplicateListenerService() { parent::testPreventDuplicateListenerService(); @@ -210,6 +211,7 @@ public function testPreventDuplicateListenerService() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testAddASubscriberService() { parent::testAddASubscriberService(); @@ -217,6 +219,7 @@ public function testAddASubscriberService() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testHasListenersOnLazyLoad() { parent::testHasListenersOnLazyLoad(); @@ -224,6 +227,7 @@ public function testHasListenersOnLazyLoad() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testGetListenersOnLazyLoad() { parent::testGetListenersOnLazyLoad(); @@ -231,6 +235,7 @@ public function testGetListenersOnLazyLoad() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testRemoveAfterDispatch() { parent::testRemoveAfterDispatch(); @@ -238,6 +243,7 @@ public function testRemoveAfterDispatch() { /** * @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead. + * @group legacy */ public function testRemoveBeforeDispatch() { parent::testRemoveBeforeDispatch(); diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php index 026154da70..08465d6381 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php @@ -61,6 +61,25 @@ public function testRegisterException() { $container->register('Bar'); } + /** + * @covers ::register + */ + public function testRegister() { + $container = new ContainerBuilder(); + $service = $container->register('bar'); + $this->assertTrue($service->isPublic()); + } + + /** + * @covers ::setAlias + */ + public function testSetAlias() { + $container = new ContainerBuilder(); + $container->register('bar'); + $alias = $container->setAlias('foo', 'bar'); + $this->assertTrue($alias->isPublic()); + } + /** * Tests serialization. */ diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php index 97b2c942d2..4093b6a2eb 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php @@ -28,6 +28,9 @@ public function testParseDefinitionsWithProvider() { services: example_service: class: \Drupal\Core\ExampleClass + example_private_service: + class: \Drupal\Core\ExampleClass + public: false YAML; vfsStream::setup('drupal', NULL, [ @@ -39,6 +42,11 @@ class: \Drupal\Core\ExampleClass $yaml_file_loader->load('vfs://drupal/modules/example/example.yml'); $this->assertEquals(['_provider' => [['provider' => 'example']]], $builder->getDefinition('example_service')->getTags()); + $this->assertTrue($builder->getDefinition('example_service')->isPublic()); + $this->assertFalse($builder->getDefinition('example_private_service')->isPublic()); + $builder->compile(); + $this->assertTrue($builder->has('example_service')); + $this->assertFalse($builder->has('example_private_service')); } }