From e95bd95e395c94ca079878a59a6114074463ea4b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 18 Jul 2022 11:01:33 +0200 Subject: [PATCH] Fix tests that use deprecated callable syntax --- .../Descriptor/AbstractDescriptorTest.php | 16 +++++++++++++++- .../Tests/Console/Descriptor/ObjectsProvider.php | 10 ++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php index d45814da781e6..fec5a980926c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -208,11 +208,25 @@ public function testDescribeCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeCallableTestData() + public function getDescribeCallableTestData(): array { return $this->getDescriptionTestData(ObjectsProvider::getCallables()); } + /** + * @group legacy + * @dataProvider getDescribeDeprecatedCallableTestData + */ + public function testDescribeDeprecatedCallable($callable, $expectedDescription) + { + $this->assertDescription($expectedDescription, $callable); + } + + public function getDescribeDeprecatedCallableTestData(): array + { + return $this->getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); + } + /** @dataProvider getClassDescriptionTestData */ public function testGetClassDescription($object, $expectedDescription) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index 05031fa7fcfb6..a097e058be7dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -229,19 +229,25 @@ public static function getEventDispatchers() return ['event_dispatcher_1' => $eventDispatcher]; } - public static function getCallables() + public static function getCallables(): array { return [ 'callable_1' => 'array_key_exists', 'callable_2' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'], 'callable_3' => [new CallableClass(), 'method'], 'callable_4' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass::staticMethod', - 'callable_5' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'], 'callable_6' => function () { return 'Closure'; }, 'callable_7' => new CallableClass(), 'callable_from_callable' => \Closure::fromCallable(new CallableClass()), ]; } + + public static function getDeprecatedCallables(): array + { + return [ + 'callable_5' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'], + ]; + } } class CallableClass