Skip to content
Snippets Groups Projects
Verified Commit ab80fb20 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3427741 by longwave, sakthi_dev, Spokje: Notify downstream users that...

Issue #3427741 by longwave, sakthi_dev, Spokje: Notify downstream users that ContainerAware is going away
parent 1feb9327
No related branches found
No related tags found
No related merge requests found
...@@ -37,8 +37,12 @@ ...@@ -37,8 +37,12 @@
%Expecting E_WARNING and E_USER_WARNING is deprecated and will no longer be possible in PHPUnit 10% %Expecting E_WARNING and E_USER_WARNING is deprecated and will no longer be possible in PHPUnit 10%
%Expecting E_ERROR and E_USER_ERROR is deprecated and will no longer be possible in PHPUnit 10% %Expecting E_ERROR and E_USER_ERROR is deprecated and will no longer be possible in PHPUnit 10%
# Temporarily for testing Symfony 6.4. # Symfony 6.4.
%Since symfony/dependency-injection 6.4: "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" is deprecated, use dependency injection instead.% %Since symfony/dependency-injection 6.4: "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" is deprecated, use dependency injection instead.%
%The ".*" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.% %The "Drupal\\Core\\Logger\\LoggerChannelFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% %The "Drupal\\Core\\Logger\\LoggerChannelFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" interface extends "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% %The "Drupal\\Core\\Queue\\QueueFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Core\\Queue\\QueueFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\Controller\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\DependencyInjection\\DependencySerializationTestDummy" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\Utility\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
...@@ -46,6 +46,7 @@ public function getInstanceFromDefinition($definition) { ...@@ -46,6 +46,7 @@ public function getInstanceFromDefinition($definition) {
} }
if ($instance instanceof ContainerAwareInterface) { if ($instance instanceof ContainerAwareInterface) {
@trigger_error('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661', E_USER_DEPRECATED);
$instance->setContainer($this->container); $instance->setContainer($this->container);
} }
......
...@@ -52,8 +52,12 @@ protected function setUp(): void { ...@@ -52,8 +52,12 @@ protected function setUp(): void {
* Tests createController(). * Tests createController().
* *
* @dataProvider providerTestCreateController * @dataProvider providerTestCreateController
* @group legacy
*/ */
public function testCreateController($controller, $class, $output) { public function testCreateController($controller, $class, $output, string $deprecation = NULL) {
if ($deprecation) {
$this->expectDeprecation($deprecation);
}
$this->container->set('some_service', new MockController()); $this->container->set('some_service', new MockController());
$result = $this->controllerResolver->getControllerFromDefinition($controller); $result = $this->controllerResolver->getControllerFromDefinition($controller);
$this->assertCallableController($result, $class, $output); $this->assertCallableController($result, $class, $output);
...@@ -71,7 +75,12 @@ public static function providerTestCreateController() { ...@@ -71,7 +75,12 @@ public static function providerTestCreateController() {
// Tests a class with injection. // Tests a class with injection.
['Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'], ['Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'],
// Tests a ContainerAware class. // Tests a ContainerAware class.
['Drupal\Tests\Core\Controller\MockContainerAware::getResult', 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'], [
'Drupal\Tests\Core\Controller\MockContainerAware::getResult',
'Drupal\Tests\Core\Controller\MockContainerAware',
'This is container aware.',
'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661',
],
]; ];
} }
...@@ -95,8 +104,12 @@ public function testCreateControllerInvalidName() { ...@@ -95,8 +104,12 @@ public function testCreateControllerInvalidName() {
* Tests getController(). * Tests getController().
* *
* @dataProvider providerTestGetController * @dataProvider providerTestGetController
* @group legacy
*/ */
public function testGetController($attributes, $class, $output = NULL) { public function testGetController($attributes, $class, $output = NULL) {
if ($class) {
$this->expectDeprecation('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661');
}
$request = new Request([], [], $attributes); $request = new Request([], [], $attributes);
$result = $this->controllerResolver->getController($request); $result = $this->controllerResolver->getController($request);
if ($class) { if ($class) {
......
...@@ -42,8 +42,12 @@ protected function setUp(): void { ...@@ -42,8 +42,12 @@ protected function setUp(): void {
/** /**
* @dataProvider callableResolverTestCases * @dataProvider callableResolverTestCases
* @covers ::getCallableFromDefinition * @covers ::getCallableFromDefinition
* @group legacy
*/ */
public function testCallbackResolver($definition, $result) { public function testCallbackResolver($definition, $result, string $deprecation = NULL) {
if ($deprecation) {
$this->expectDeprecation($deprecation);
}
$argument = 'bar'; $argument = 'bar';
$this->assertEquals($result . '+' . $argument, $this->resolver->getCallableFromDefinition($definition)($argument)); $this->assertEquals($result . '+' . $argument, $this->resolver->getCallableFromDefinition($definition)($argument));
} }
...@@ -98,6 +102,7 @@ function ($suffix) { ...@@ -98,6 +102,7 @@ function ($suffix) {
'Non-static function, instantiated by class resolver, container aware' => [ 'Non-static function, instantiated by class resolver, container aware' => [
'\Drupal\Tests\Core\Utility\MockContainerAware::getResult', '\Drupal\Tests\Core\Utility\MockContainerAware::getResult',
'Drupal\Tests\Core\Utility\MockContainerAware::getResult', 'Drupal\Tests\Core\Utility\MockContainerAware::getResult',
'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661',
], ],
'Service notation' => [ 'Service notation' => [
'test_service:method', 'test_service:method',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment