diff --git a/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.install b/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.install index 2ab3e6b498..552d6912c8 100644 --- a/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.install +++ b/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.install @@ -17,6 +17,7 @@ function new_dependency_test_update_8001() { 'new_dependency_test.alias_dependency', 'new_dependency_test.alias2', 'new_dependency_test.alias_dependency2', + 'new_dependency_test.setter_injection', ]; // Gather the state of the services prior to installing the diff --git a/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml b/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml index a3283daea8..1f1c4ca29a 100644 --- a/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml +++ b/core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml @@ -34,3 +34,7 @@ services: decorates: new_dependency_test.another_service_two decoration_inner_name: new_dependency_test.foo arguments: ['@new_dependency_test.foo'] + new_dependency_test.setter_injection: + class: Drupal\new_dependency_test\SetterInjection + calls: + - [setter, ['@new_dependency_test_with_service.service']] diff --git a/core/modules/system/tests/modules/new_dependency_test/src/SetterInjection.php b/core/modules/system/tests/modules/new_dependency_test/src/SetterInjection.php new file mode 100644 index 0000000000..4ee971e976 --- /dev/null +++ b/core/modules/system/tests/modules/new_dependency_test/src/SetterInjection.php @@ -0,0 +1,39 @@ +service = $service; + } + + /** + * Get the simple greeting from the service. + * + * @return string + * The greeting. + */ + public function greet() { + return $this->service->greet(); + } + +} diff --git a/core/modules/system/tests/src/Functional/Update/UpdatePathNewDependencyTest.php b/core/modules/system/tests/src/Functional/Update/UpdatePathNewDependencyTest.php index 57a53278c4..2d3058a27b 100644 --- a/core/modules/system/tests/src/Functional/Update/UpdatePathNewDependencyTest.php +++ b/core/modules/system/tests/src/Functional/Update/UpdatePathNewDependencyTest.php @@ -58,6 +58,7 @@ public function testUpdateNewDependency() { $this->assertEquals('Hello', $this->container->get('new_dependency_test.alias')->greet()); $this->assertEquals('Hello World', $this->container->get('new_dependency_test.hard_dependency')->greet()); $this->assertEquals('Hello World', $this->container->get('new_dependency_test.optional_dependency')->greet()); + $this->assertEquals('Hello', $this->container->get('new_dependency_test.setter_injection')->greet()); // Tests that existing decorated services work as expected during update. $this->assertTrue(\Drupal::state()->get('new_dependency_test_update_8001.decorated_service'), 'The new_dependency_test.another_service service is decorated'); @@ -73,6 +74,7 @@ public function testUpdateNewDependency() { 'new_dependency_test.alias_dependency' => FALSE, 'new_dependency_test.alias2' => FALSE, 'new_dependency_test.alias_dependency2' => FALSE, + 'new_dependency_test.setter_injection' => FALSE, ], $before_install); $after_install = \Drupal::state()->get('new_dependency_test_update_8001.has_after_install', []); @@ -84,6 +86,7 @@ public function testUpdateNewDependency() { 'new_dependency_test.alias_dependency' => TRUE, 'new_dependency_test.alias2' => TRUE, 'new_dependency_test.alias_dependency2' => TRUE, + 'new_dependency_test.setter_injection' => TRUE, ], $after_install); }