From 9ce1f1a939eb7ca9f03bbfdcf8523d8abcdc1a2d Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sun, 15 Jan 2023 18:57:26 +0100 Subject: [PATCH 01/21] [Tests] New iteration of removing `$this` occurrences in future static data providers --- .../Descriptor/AbstractDescriptorTest.php | 79 ++++++++++--------- .../Console/Descriptor/JsonDescriptorTest.php | 4 +- .../Descriptor/MarkdownDescriptorTest.php | 4 +- .../Console/Descriptor/TextDescriptorTest.php | 14 ++-- .../Console/Descriptor/XmlDescriptorTest.php | 4 +- 5 files changed, 53 insertions(+), 52 deletions(-) diff --git a/Tests/Console/Descriptor/AbstractDescriptorTest.php b/Tests/Console/Descriptor/AbstractDescriptorTest.php index d761ca538..9efc7eda1 100644 --- a/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -45,9 +45,9 @@ public function testDescribeRouteCollection(RouteCollection $routes, $expectedDe $this->assertDescription($expectedDescription, $routes); } - public function getDescribeRouteCollectionTestData() + public static function getDescribeRouteCollectionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getRouteCollections()); + return static::getDescriptionTestData(ObjectsProvider::getRouteCollections()); } /** @dataProvider getDescribeRouteTestData */ @@ -56,9 +56,9 @@ public function testDescribeRoute(Route $route, $expectedDescription) $this->assertDescription($expectedDescription, $route); } - public function getDescribeRouteTestData() + public static function getDescribeRouteTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getRoutes()); + return static::getDescriptionTestData(ObjectsProvider::getRoutes()); } /** @dataProvider getDescribeContainerParametersTestData */ @@ -67,9 +67,9 @@ public function testDescribeContainerParameters(ParameterBag $parameters, $expec $this->assertDescription($expectedDescription, $parameters); } - public function getDescribeContainerParametersTestData() + public static function getDescribeContainerParametersTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerParameters()); + return static::getDescriptionTestData(ObjectsProvider::getContainerParameters()); } /** @dataProvider getDescribeContainerBuilderTestData */ @@ -78,9 +78,9 @@ public function testDescribeContainerBuilder(ContainerBuilder $builder, $expecte $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerBuilderTestData() + public static function getDescribeContainerBuilderTestData(): array { - return $this->getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); + return static::getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); } /** @@ -91,9 +91,9 @@ public function testDescribeContainerExistingClassDefinition(Definition $definit $this->assertDescription($expectedDescription, $definition); } - public function getDescribeContainerExistingClassDefinitionTestData() + public static function getDescribeContainerExistingClassDefinitionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitionsWithExistingClasses()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitionsWithExistingClasses()); } /** @dataProvider getDescribeContainerDefinitionTestData */ @@ -102,9 +102,9 @@ public function testDescribeContainerDefinition(Definition $definition, $expecte $this->assertDescription($expectedDescription, $definition); } - public function getDescribeContainerDefinitionTestData() + public static function getDescribeContainerDefinitionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); } /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */ @@ -113,7 +113,7 @@ public function testDescribeContainerDefinitionWithArgumentsShown(Definition $de $this->assertDescription($expectedDescription, $definition, ['show_arguments' => true]); } - public function getDescribeContainerDefinitionWithArgumentsShownTestData() + public static function getDescribeContainerDefinitionWithArgumentsShownTestData(): array { $definitions = ObjectsProvider::getContainerDefinitions(); $definitionsWithArgs = []; @@ -126,7 +126,7 @@ public function getDescribeContainerDefinitionWithArgumentsShownTestData() $definitionsWithArgs['definition_arguments_with_enum'] = (new Definition('definition_with_enum'))->setArgument(0, FooUnitEnum::FOO); } - return $this->getDescriptionTestData($definitionsWithArgs); + return static::getDescriptionTestData($definitionsWithArgs); } /** @dataProvider getDescribeContainerAliasTestData */ @@ -135,9 +135,9 @@ public function testDescribeContainerAlias(Alias $alias, $expectedDescription) $this->assertDescription($expectedDescription, $alias); } - public function getDescribeContainerAliasTestData() + public static function getDescribeContainerAliasTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerAliases()); + return static::getDescriptionTestData(ObjectsProvider::getContainerAliases()); } /** @dataProvider getDescribeContainerDefinitionWhichIsAnAliasTestData */ @@ -146,7 +146,7 @@ public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $exp $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerDefinitionWhichIsAnAliasTestData() + public static function getDescribeContainerDefinitionWhichIsAnAliasTestData(): array { $builder = current(ObjectsProvider::getContainerBuilders()); $builder->setDefinition('service_1', $builder->getDefinition('definition_1')); @@ -159,7 +159,7 @@ public function getDescribeContainerDefinitionWhichIsAnAliasTestData() } $i = 0; - $data = $this->getDescriptionTestData($aliasesWithDefinitions); + $data = static::getDescriptionTestData($aliasesWithDefinitions); foreach ($aliases as $name => $alias) { $file = array_pop($data[$i]); $data[$i][] = $builder; @@ -177,9 +177,9 @@ public function testDescribeContainerParameter($parameter, $expectedDescription, $this->assertDescription($expectedDescription, $parameter, $options); } - public function getDescribeContainerParameterTestData() + public static function getDescribeContainerParameterTestData(): array { - $data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter()); + $data = static::getDescriptionTestData(ObjectsProvider::getContainerParameter()); $file = array_pop($data[0]); $data[0][] = ['parameter' => 'database_name']; @@ -197,9 +197,9 @@ public function testDescribeEventDispatcher(EventDispatcher $eventDispatcher, $e $this->assertDescription($expectedDescription, $eventDispatcher, $options); } - public function getDescribeEventDispatcherTestData() + public static function getDescribeEventDispatcherTestData(): array { - return $this->getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); + return static::getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); } /** @dataProvider getDescribeCallableTestData */ @@ -208,13 +208,14 @@ public function testDescribeCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeCallableTestData(): array + public static function getDescribeCallableTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getCallables()); + return static::getDescriptionTestData(ObjectsProvider::getCallables()); } /** * @group legacy + * * @dataProvider getDescribeDeprecatedCallableTestData */ public function testDescribeDeprecatedCallable($callable, $expectedDescription) @@ -222,9 +223,9 @@ public function testDescribeDeprecatedCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeDeprecatedCallableTestData(): array + public static function getDescribeDeprecatedCallableTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); + return static::getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); } /** @dataProvider getClassDescriptionTestData */ @@ -233,7 +234,7 @@ public function testGetClassDescription($object, $expectedDescription) $this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object)); } - public function getClassDescriptionTestData() + public static function getClassDescriptionTestData(): array { return [ [ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'], @@ -251,14 +252,14 @@ public function testGetDeprecations(ContainerBuilder $builder, $expectedDescript $this->assertDescription($expectedDescription, $builder, ['deprecations' => true]); } - public function getDeprecationsTestData() + public static function getDeprecationsTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDeprecations()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDeprecations()); } - abstract protected function getDescriptor(); + abstract protected static function getDescriptor(); - abstract protected function getFormat(); + abstract protected static function getFormat(); private function assertDescription($expectedDescription, $describedObject, array $options = []) { @@ -280,11 +281,11 @@ private function assertDescription($expectedDescription, $describedObject, array } } - private function getDescriptionTestData(iterable $objects) + private static function getDescriptionTestData(iterable $objects): array { $data = []; foreach ($objects as $name => $object) { - $file = sprintf('%s.%s', trim($name, '.'), $this->getFormat()); + $file = sprintf('%s.%s', trim($name, '.'), static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $file]; } @@ -292,7 +293,7 @@ private function getDescriptionTestData(iterable $objects) return $data; } - private function getContainerBuilderDescriptionTestData(array $objects) + private static function getContainerBuilderDescriptionTestData(array $objects): array { $variations = [ 'services' => ['show_hidden' => true], @@ -305,7 +306,7 @@ private function getContainerBuilderDescriptionTestData(array $objects) $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options, $file]; } @@ -314,7 +315,7 @@ private function getContainerBuilderDescriptionTestData(array $objects) return $data; } - private function getEventDispatcherDescriptionTestData(array $objects) + private static function getEventDispatcherDescriptionTestData(array $objects): array { $variations = [ 'events' => [], @@ -324,7 +325,7 @@ private function getEventDispatcherDescriptionTestData(array $objects) $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options, $file]; } @@ -339,13 +340,13 @@ public function testDescribeContainerBuilderWithPriorityTags(ContainerBuilder $b $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerBuilderWithPriorityTagsTestData(): array + public static function getDescribeContainerBuilderWithPriorityTagsTestData(): array { $variations = ['priority_tag' => ['tag' => 'tag1']]; $data = []; foreach (ObjectsProvider::getContainerBuildersWithPriorityTags() as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options]; } diff --git a/Tests/Console/Descriptor/JsonDescriptorTest.php b/Tests/Console/Descriptor/JsonDescriptorTest.php index ee03f6539..723b45b00 100644 --- a/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -15,12 +15,12 @@ class JsonDescriptorTest extends AbstractDescriptorTest { - protected function getDescriptor() + protected static function getDescriptor() { return new JsonDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'json'; } diff --git a/Tests/Console/Descriptor/MarkdownDescriptorTest.php b/Tests/Console/Descriptor/MarkdownDescriptorTest.php index fbb5aaa96..596ba4747 100644 --- a/Tests/Console/Descriptor/MarkdownDescriptorTest.php +++ b/Tests/Console/Descriptor/MarkdownDescriptorTest.php @@ -15,12 +15,12 @@ class MarkdownDescriptorTest extends AbstractDescriptorTest { - protected function getDescriptor() + protected static function getDescriptor() { return new MarkdownDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'md'; } diff --git a/Tests/Console/Descriptor/TextDescriptorTest.php b/Tests/Console/Descriptor/TextDescriptorTest.php index b844a60e7..cc011e651 100644 --- a/Tests/Console/Descriptor/TextDescriptorTest.php +++ b/Tests/Console/Descriptor/TextDescriptorTest.php @@ -17,21 +17,21 @@ class TextDescriptorTest extends AbstractDescriptorTest { - private $fileLinkFormatter = null; + private static $fileLinkFormatter = null; - protected function getDescriptor() + protected static function getDescriptor() { - return new TextDescriptor($this->fileLinkFormatter); + return new TextDescriptor(static::$fileLinkFormatter); } - protected function getFormat() + protected static function getFormat() { return 'txt'; } - public function getDescribeRouteWithControllerLinkTestData() + public static function getDescribeRouteWithControllerLinkTestData() { - $getDescribeData = $this->getDescribeRouteTestData(); + $getDescribeData = static::getDescribeRouteTestData(); foreach ($getDescribeData as $key => &$data) { $routeStub = $data[0]; @@ -48,7 +48,7 @@ public function getDescribeRouteWithControllerLinkTestData() /** @dataProvider getDescribeRouteWithControllerLinkTestData */ public function testDescribeRouteWithControllerLink(Route $route, $expectedDescription) { - $this->fileLinkFormatter = new FileLinkFormatter('myeditor://open?file=%f&line=%l'); + static::$fileLinkFormatter = new FileLinkFormatter('myeditor://open?file=%f&line=%l'); parent::testDescribeRoute($route, str_replace('[:file:]', __FILE__, $expectedDescription)); } } diff --git a/Tests/Console/Descriptor/XmlDescriptorTest.php b/Tests/Console/Descriptor/XmlDescriptorTest.php index 8cb9a7169..286f49be4 100644 --- a/Tests/Console/Descriptor/XmlDescriptorTest.php +++ b/Tests/Console/Descriptor/XmlDescriptorTest.php @@ -15,12 +15,12 @@ class XmlDescriptorTest extends AbstractDescriptorTest { - protected function getDescriptor() + protected static function getDescriptor() { return new XmlDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'xml'; } From c2c7151c5ea815677012921067c473ecf6c9e437 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 24 Jan 2023 15:02:24 +0100 Subject: [PATCH 02/21] Update license years (last time) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 008370457..0138f8f07 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From a95ab3535339efa1629c7ccd97dfd9fd8aa93533 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Feb 2023 10:31:13 +0100 Subject: [PATCH 03/21] minor #49253 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` (OskarStark) This PR was merged into the 6.3 branch. Discussion ---------- [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Refs https://github.com/symfony/symfony/pull/49233 | License | MIT | Doc PR | n/a Replaces #49234 Using `Test` suffix is deprecated since PHPUnit 10 Spotted in * https://github.com/symfony/symfony/pull/49233 Commits ------- cb3db968e4 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` --- ...tDescriptorTest.php => AbstractDescriptorTestCase.php} | 2 +- Tests/Console/Descriptor/JsonDescriptorTest.php | 2 +- Tests/Console/Descriptor/MarkdownDescriptorTest.php | 2 +- Tests/Console/Descriptor/TextDescriptorTest.php | 2 +- Tests/Console/Descriptor/XmlDescriptorTest.php | 2 +- .../Fixtures/php/workflow_not_valid.php | 4 ++-- .../Fixtures/php/workflow_with_guard_expression.php | 4 ++-- .../workflow_with_multiple_transitions_with_same_name.php | 4 ++-- .../Fixtures/php/workflow_with_no_events_to_dispatch.php | 4 ++-- .../php/workflow_with_specified_events_to_dispatch.php | 4 ++-- .../php/workflow_with_support_and_support_strategy.php | 4 ++-- Tests/DependencyInjection/Fixtures/php/workflows.php | 8 ++++---- .../Fixtures/php/workflows_explicitly_enabled.php | 4 +++- .../php/workflows_explicitly_enabled_named_workflows.php | 4 +++- .../Fixtures/xml/workflow_not_valid.xml | 2 +- .../Fixtures/xml/workflow_with_guard_expression.xml | 2 +- .../workflow_with_multiple_transitions_with_same_name.xml | 2 +- .../Fixtures/xml/workflow_with_no_events_to_dispatch.xml | 2 +- .../xml/workflow_with_specified_events_to_dispatch.xml | 2 +- .../xml/workflow_with_support_and_support_strategy.xml | 2 +- Tests/DependencyInjection/Fixtures/xml/workflows.xml | 6 +++--- .../Fixtures/xml/workflows_explicitly_enabled.xml | 2 +- .../xml/workflows_explicitly_enabled_named_workflows.xml | 2 +- .../Fixtures/yml/workflow_not_valid.yml | 2 +- .../Fixtures/yml/workflow_with_guard_expression.yml | 2 +- .../workflow_with_multiple_transitions_with_same_name.yml | 2 +- .../Fixtures/yml/workflow_with_no_events_to_dispatch.yml | 2 +- .../yml/workflow_with_specified_events_to_dispatch.yml | 2 +- .../yml/workflow_with_support_and_support_strategy.yml | 2 +- Tests/DependencyInjection/Fixtures/yml/workflows.yml | 6 +++--- .../Fixtures/yml/workflows_explicitly_enabled.yml | 2 +- .../yml/workflows_explicitly_enabled_named_workflows.yml | 2 +- ...rkExtensionTest.php => FrameworkExtensionTestCase.php} | 2 +- Tests/DependencyInjection/PhpFrameworkExtensionTest.php | 2 +- Tests/DependencyInjection/XmlFrameworkExtensionTest.php | 2 +- Tests/DependencyInjection/YamlFrameworkExtensionTest.php | 2 +- 36 files changed, 53 insertions(+), 49 deletions(-) rename Tests/Console/Descriptor/{AbstractDescriptorTest.php => AbstractDescriptorTestCase.php} (99%) rename Tests/DependencyInjection/{FrameworkExtensionTest.php => FrameworkExtensionTestCase.php} (99%) diff --git a/Tests/Console/Descriptor/AbstractDescriptorTest.php b/Tests/Console/Descriptor/AbstractDescriptorTestCase.php similarity index 99% rename from Tests/Console/Descriptor/AbstractDescriptorTest.php rename to Tests/Console/Descriptor/AbstractDescriptorTestCase.php index 9efc7eda1..67c067841 100644 --- a/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/Tests/Console/Descriptor/AbstractDescriptorTestCase.php @@ -24,7 +24,7 @@ use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -abstract class AbstractDescriptorTest extends TestCase +abstract class AbstractDescriptorTestCase extends TestCase { private $colSize; diff --git a/Tests/Console/Descriptor/JsonDescriptorTest.php b/Tests/Console/Descriptor/JsonDescriptorTest.php index 723b45b00..296737a92 100644 --- a/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -13,7 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor; -class JsonDescriptorTest extends AbstractDescriptorTest +class JsonDescriptorTest extends AbstractDescriptorTestCase { protected static function getDescriptor() { diff --git a/Tests/Console/Descriptor/MarkdownDescriptorTest.php b/Tests/Console/Descriptor/MarkdownDescriptorTest.php index 596ba4747..1a653b835 100644 --- a/Tests/Console/Descriptor/MarkdownDescriptorTest.php +++ b/Tests/Console/Descriptor/MarkdownDescriptorTest.php @@ -13,7 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\MarkdownDescriptor; -class MarkdownDescriptorTest extends AbstractDescriptorTest +class MarkdownDescriptorTest extends AbstractDescriptorTestCase { protected static function getDescriptor() { diff --git a/Tests/Console/Descriptor/TextDescriptorTest.php b/Tests/Console/Descriptor/TextDescriptorTest.php index cc011e651..55e410597 100644 --- a/Tests/Console/Descriptor/TextDescriptorTest.php +++ b/Tests/Console/Descriptor/TextDescriptorTest.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\Routing\Route; -class TextDescriptorTest extends AbstractDescriptorTest +class TextDescriptorTest extends AbstractDescriptorTestCase { private static $fileLinkFormatter = null; diff --git a/Tests/Console/Descriptor/XmlDescriptorTest.php b/Tests/Console/Descriptor/XmlDescriptorTest.php index 286f49be4..5b263b817 100644 --- a/Tests/Console/Descriptor/XmlDescriptorTest.php +++ b/Tests/Console/Descriptor/XmlDescriptorTest.php @@ -13,7 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\XmlDescriptor; -class XmlDescriptorTest extends AbstractDescriptorTest +class XmlDescriptorTest extends AbstractDescriptorTestCase { protected static function getDescriptor() { diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php b/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php index 5d6ed54d6..cfad547bd 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'my_workflow' => [ 'type' => 'state_machine', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'places' => [ 'first', diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php index 2037b5f90..1b4dbfefd 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'places' => [ diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php index 35a9df373..aef7f5095 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'places' => [ diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php index e4eefd4c2..287095895 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php @@ -1,6 +1,6 @@ loadFromExtension('framework', [ 'workflows' => [ @@ -11,7 +11,7 @@ 'property' => 'state', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'events_to_dispatch' => [], 'places' => [ diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php index 0fc5c29c8..a0414cee2 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php @@ -1,6 +1,6 @@ loadFromExtension('framework', [ 'workflows' => [ @@ -11,7 +11,7 @@ 'property' => 'state', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'events_to_dispatch' => [ 'workflow.leave', diff --git a/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php index 063755b13..c2acce156 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php +++ b/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'my_workflow' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'support_strategy' => 'foobar', 'places' => [ diff --git a/Tests/DependencyInjection/Fixtures/php/workflows.php b/Tests/DependencyInjection/Fixtures/php/workflows.php index 995fabffe..fd2d71459 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'metadata' => [ @@ -43,7 +43,7 @@ ], 'pull_request' => [ 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => 'start', 'metadata' => [ @@ -102,7 +102,7 @@ 'service' => 'workflow_service', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'places' => [ ['name' => 'first'], diff --git a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php index f048de1ce..53ce0ec07 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php @@ -1,11 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'enabled' => true, 'foo' => [ 'type' => 'workflow', - 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], + 'supports' => [FrameworkExtensionTestCase::class], 'initial_marking' => ['bar'], 'places' => ['bar', 'baz'], 'transitions' => [ diff --git a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php index f79a2d10e..b954889b6 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php @@ -1,11 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'enabled' => true, 'workflows' => [ 'type' => 'workflow', - 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], + 'supports' => [FrameworkExtensionTestCase::class], 'initial_marking' => ['bar'], 'places' => ['bar', 'baz'], 'transitions' => [ diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml index df299c89d..1aa7b099a 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml @@ -8,7 +8,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml index ffc12c4d0..6420f099b 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml @@ -9,7 +9,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase draft wait_for_journalist approved_by_journalist diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml index db79f9323..815c83aff 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml @@ -9,7 +9,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml index 2f563da4b..4842e54bf 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml @@ -10,7 +10,7 @@ one - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml index d442828f8..d154c91b5 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml @@ -10,7 +10,7 @@ one - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase workflow.leave workflow.completed diff --git a/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml b/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml index 54a346ebd..c6170b6fe 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml @@ -8,7 +8,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/Tests/DependencyInjection/Fixtures/xml/workflows.xml b/Tests/DependencyInjection/Fixtures/xml/workflows.xml index 79361af57..ba373aad2 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflows.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflows.xml @@ -11,7 +11,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase @@ -45,7 +45,7 @@ start - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase place start title @@ -96,7 +96,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase first last diff --git a/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml b/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml index af93d44e1..c27c51d06 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml @@ -7,7 +7,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase bar baz diff --git a/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml b/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml index 41fd29a1f..34e58c86d 100644 --- a/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml +++ b/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml @@ -8,7 +8,7 @@ bar - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase bar baz diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml index 123505de9..2228751bf 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml @@ -3,7 +3,7 @@ framework: my_workflow: type: state_machine supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: [first, middle, last] transitions: go: diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml index 80a85a307..d3012f77a 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] places: - draft diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml index 12df7b79e..d5e3f7fec 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] places: - draft diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml index e0a281f27..dadc41899 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml @@ -8,7 +8,7 @@ framework: type: method property: state supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - one - two diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml index d5ff3d5e5..98fe5d961 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml @@ -8,7 +8,7 @@ framework: type: method property: state supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - one - two diff --git a/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml b/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml index de0b36d8f..1b043700b 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml @@ -3,7 +3,7 @@ framework: my_workflow: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase support_strategy: foobar places: - first diff --git a/Tests/DependencyInjection/Fixtures/yml/workflows.yml b/Tests/DependencyInjection/Fixtures/yml/workflows.yml index e4ac9c018..455ec7271 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflows.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflows.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] metadata: title: article workflow @@ -31,7 +31,7 @@ framework: to: [published] pull_request: supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: start metadata: title: workflow title @@ -74,7 +74,7 @@ framework: marking_store: service: workflow_service supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - { name: first } - { name: last } diff --git a/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml b/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml index bbecf4bfc..685ea9733 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml @@ -5,7 +5,7 @@ framework: foo: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [bar] places: - bar diff --git a/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml b/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml index 786e3bcad..d97e72bb3 100644 --- a/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml +++ b/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml @@ -4,7 +4,7 @@ framework: workflows: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [bar] places: - bar diff --git a/Tests/DependencyInjection/FrameworkExtensionTest.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php similarity index 99% rename from Tests/DependencyInjection/FrameworkExtensionTest.php rename to Tests/DependencyInjection/FrameworkExtensionTestCase.php index f212a6db8..9abcaf40e 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -79,7 +79,7 @@ use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; -abstract class FrameworkExtensionTest extends TestCase +abstract class FrameworkExtensionTestCase extends TestCase { use ExpectDeprecationTrait; diff --git a/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index d9f4b1192..c763e2bd2 100644 --- a/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\Workflow\Exception\InvalidDefinitionException; -class PhpFrameworkExtensionTest extends FrameworkExtensionTest +class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { diff --git a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 131bb07f0..944e19709 100644 --- a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -class XmlFrameworkExtensionTest extends FrameworkExtensionTest +class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { diff --git a/Tests/DependencyInjection/YamlFrameworkExtensionTest.php b/Tests/DependencyInjection/YamlFrameworkExtensionTest.php index 457467aa1..cb5a0a5e1 100644 --- a/Tests/DependencyInjection/YamlFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/YamlFrameworkExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -class YamlFrameworkExtensionTest extends FrameworkExtensionTest +class YamlFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { From 7fc16c502a08c6fd1bd93edab881ea59ce54d316 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Fri, 21 Oct 2022 17:52:33 +0200 Subject: [PATCH 04/21] [FrameworkBundle] Fix checkboxes check assertions --- Test/DomCrawlerAssertionsTrait.php | 11 ++--------- Tests/Test/WebTestCaseTest.php | 6 ++++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Test/DomCrawlerAssertionsTrait.php b/Test/DomCrawlerAssertionsTrait.php index 2a692d6f5..6e8247cbf 100644 --- a/Test/DomCrawlerAssertionsTrait.php +++ b/Test/DomCrawlerAssertionsTrait.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\Constraint\LogicalNot; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint; -use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorAttributeValueSame; use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorExists; /** @@ -87,18 +86,12 @@ public static function assertInputValueNotSame(string $fieldName, string $expect public static function assertCheckboxChecked(string $fieldName, string $message = ''): void { - self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( - new CrawlerSelectorExists("input[name=\"$fieldName\"]"), - new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked') - ), $message); + self::assertThat(self::getCrawler(), new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"), $message); } public static function assertCheckboxNotChecked(string $fieldName, string $message = ''): void { - self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( - new CrawlerSelectorExists("input[name=\"$fieldName\"]"), - new LogicalNot(new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked')) - ), $message); + self::assertThat(self::getCrawler(), new LogicalNot(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")), $message); } public static function assertFormValue(string $formSelector, string $fieldName, string $value, string $message = ''): void diff --git a/Tests/Test/WebTestCaseTest.php b/Tests/Test/WebTestCaseTest.php index f6098ea6e..8f0c8fb42 100644 --- a/Tests/Test/WebTestCaseTest.php +++ b/Tests/Test/WebTestCaseTest.php @@ -238,16 +238,18 @@ public function testAssertInputValueNotSame() public function testAssertCheckboxChecked() { $this->getCrawlerTester(new Crawler('
'))->assertCheckboxChecked('rememberMe'); + $this->getCrawlerTester(new Crawler(''))->assertCheckboxChecked('rememberMe'); $this->expectException(AssertionFailedError::class); - $this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and has a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".'); + $this->expectExceptionMessage('matches selector "input[name="rememberMe"]:checked".'); $this->getCrawlerTester(new Crawler(''))->assertCheckboxChecked('rememberMe'); } public function testAssertCheckboxNotChecked() { $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); + $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); $this->expectException(AssertionFailedError::class); - $this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and does not have a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".'); + $this->expectExceptionMessage('does not match selector "input[name="rememberMe"]:checked".'); $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); } From 3265f8871c61f94b05518432d48757baf4f7b57f Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 10 Feb 2023 18:11:10 +0100 Subject: [PATCH 05/21] [FrameworkBundle] Improve error message in MicroKernelTrait when using deprecated configureRoutes(RouteCollectionBuilder) with symfony/routing >= 6.0 --- Kernel/MicroKernelTrait.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/MicroKernelTrait.php b/Kernel/MicroKernelTrait.php index c25f90d63..e448d2d8a 100644 --- a/Kernel/MicroKernelTrait.php +++ b/Kernel/MicroKernelTrait.php @@ -213,6 +213,10 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection if ($configuratorClass && !is_a(RoutingConfigurator::class, $configuratorClass, true)) { trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class); + if (!class_exists(RouteCollectionBuilder::class)) { + throw new \InvalidArgumentException(sprintf('Using type "%s" for argument 1 of method "%s:configureRoutes()" is not compatible with the installed "symfony/routing" version. Use "%s" instead, or run "composer require symfony/routing:^5.4".', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class)); + } + $routes = new RouteCollectionBuilder($loader); $this->configureRoutes($routes); From 737cb97290de6ca07678ee19098213a4b6f51ee2 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 14 Dec 2022 15:42:16 +0100 Subject: [PATCH 06/21] Migrate to `static` data providers using `rector/rector` --- Tests/CacheWarmer/SerializerCacheWarmerTest.php | 2 +- Tests/Command/CachePoolClearCommandTest.php | 2 +- Tests/Command/CachePoolDeleteCommandTest.php | 2 +- Tests/Command/EventDispatcherDebugCommandTest.php | 2 +- Tests/Command/SecretsRemoveCommandTest.php | 2 +- Tests/Command/SecretsSetCommandTest.php | 2 +- Tests/Command/TranslationDebugCommandTest.php | 2 +- Tests/Command/TranslationUpdateCommandCompletionTest.php | 2 +- Tests/Command/WorkflowDumpCommandTest.php | 2 +- Tests/Controller/RedirectControllerTest.php | 6 +++--- .../Compiler/DataCollectorTranslatorPassTest.php | 4 ++-- Tests/DependencyInjection/Compiler/ProfilerPassTest.php | 2 +- Tests/DependencyInjection/ConfigurationTest.php | 8 ++++---- Tests/DependencyInjection/FrameworkExtensionTestCase.php | 4 ++-- Tests/Functional/AnnotatedControllerTest.php | 2 +- Tests/Functional/ConfigDebugCommandTest.php | 2 +- Tests/Functional/ConfigDumpReferenceCommandTest.php | 2 +- Tests/Functional/ContainerDebugCommandTest.php | 4 ++-- Tests/Functional/DebugAutowiringCommandTest.php | 2 +- Tests/Functional/FragmentTest.php | 2 +- Tests/Functional/ProfilerTest.php | 2 +- Tests/Functional/RouterDebugCommandTest.php | 2 +- Tests/Functional/SecurityTest.php | 2 +- Tests/Functional/SerializerTest.php | 2 +- Tests/Functional/SessionTest.php | 2 +- Tests/Routing/RouterTest.php | 4 ++-- Tests/Translation/TranslatorTest.php | 2 +- 27 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/Tests/CacheWarmer/SerializerCacheWarmerTest.php index e64196f64..85dbd8810 100644 --- a/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -40,7 +40,7 @@ public function testWarmUp(array $loaders) $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); } - public function loaderProvider() + public static function loaderProvider() { return [ [ diff --git a/Tests/Command/CachePoolClearCommandTest.php b/Tests/Command/CachePoolClearCommandTest.php index 169fcd8c2..cc4573faf 100644 --- a/Tests/Command/CachePoolClearCommandTest.php +++ b/Tests/Command/CachePoolClearCommandTest.php @@ -44,7 +44,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'pool_name' => [ ['f'], diff --git a/Tests/Command/CachePoolDeleteCommandTest.php b/Tests/Command/CachePoolDeleteCommandTest.php index f643bc125..7cd236670 100644 --- a/Tests/Command/CachePoolDeleteCommandTest.php +++ b/Tests/Command/CachePoolDeleteCommandTest.php @@ -98,7 +98,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'pool_name' => [ ['f'], diff --git a/Tests/Command/EventDispatcherDebugCommandTest.php b/Tests/Command/EventDispatcherDebugCommandTest.php index a506ac2d2..9bc054f22 100644 --- a/Tests/Command/EventDispatcherDebugCommandTest.php +++ b/Tests/Command/EventDispatcherDebugCommandTest.php @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']]; yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']]; diff --git a/Tests/Command/SecretsRemoveCommandTest.php b/Tests/Command/SecretsRemoveCommandTest.php index c02bc9176..88c247ec6 100644 --- a/Tests/Command/SecretsRemoveCommandTest.php +++ b/Tests/Command/SecretsRemoveCommandTest.php @@ -37,7 +37,7 @@ public function testComplete(bool $withLocalVault, array $input, array $expected $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'name' => [true, [''], ['SECRET', 'OTHER_SECRET']]; yield '--local name (with local vault)' => [true, ['--local', ''], ['SECRET']]; diff --git a/Tests/Command/SecretsSetCommandTest.php b/Tests/Command/SecretsSetCommandTest.php index 135907b37..8e8e968c8 100644 --- a/Tests/Command/SecretsSetCommandTest.php +++ b/Tests/Command/SecretsSetCommandTest.php @@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'name' => [[''], ['SECRET', 'OTHER_SECRET']]; yield '--local name (with local vault)' => [['--local', ''], ['SECRET', 'OTHER_SECRET']]; diff --git a/Tests/Command/TranslationDebugCommandTest.php b/Tests/Command/TranslationDebugCommandTest.php index 70f94d6a3..846abd445 100644 --- a/Tests/Command/TranslationDebugCommandTest.php +++ b/Tests/Command/TranslationDebugCommandTest.php @@ -269,7 +269,7 @@ function ($path, $catalogue) use ($extractedMessagesWithDomains) { $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'locale' => [ [''], diff --git a/Tests/Command/TranslationUpdateCommandCompletionTest.php b/Tests/Command/TranslationUpdateCommandCompletionTest.php index 49ba74caf..91999d288 100644 --- a/Tests/Command/TranslationUpdateCommandCompletionTest.php +++ b/Tests/Command/TranslationUpdateCommandCompletionTest.php @@ -42,7 +42,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { $bundle = new ExtensionPresentBundle(); diff --git a/Tests/Command/WorkflowDumpCommandTest.php b/Tests/Command/WorkflowDumpCommandTest.php index 13a63b40d..d28f53261 100644 --- a/Tests/Command/WorkflowDumpCommandTest.php +++ b/Tests/Command/WorkflowDumpCommandTest.php @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'option --dump-format' => [['--dump-format', ''], ['puml', 'mermaid', 'dot']]; } diff --git a/Tests/Controller/RedirectControllerTest.php b/Tests/Controller/RedirectControllerTest.php index 70ccf7c97..de72396df 100644 --- a/Tests/Controller/RedirectControllerTest.php +++ b/Tests/Controller/RedirectControllerTest.php @@ -103,7 +103,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign $this->assertEquals($expectedCode, $returnResponse->getStatusCode()); } - public function provider() + public static function provider() { return [ [true, false, false, false, 301, ['additional-parameter' => 'value']], @@ -210,7 +210,7 @@ public function testUrlRedirectDefaultPorts() $this->assertRedirectUrl($returnValue, $expectedUrl); } - public function urlRedirectProvider() + public static function urlRedirectProvider() { return [ // Standard ports @@ -262,7 +262,7 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, $this->assertRedirectUrl($returnValue, $expectedUrl); } - public function pathQueryParamsProvider() + public static function pathQueryParamsProvider() { return [ ['http://www.example.com/base/redirect-path', '/redirect-path', ''], diff --git a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index 0167f5510..a5d58edbb 100644 --- a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -65,7 +65,7 @@ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBag $this->assertTrue($this->container->hasDefinition('data_collector.translation')); } - public function getImplementingTranslatorBagInterfaceTranslatorClassNames() + public static function getImplementingTranslatorBagInterfaceTranslatorClassNames() { return [ ['Symfony\Component\Translation\Translator'], @@ -97,7 +97,7 @@ public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTrans $this->assertFalse($this->container->hasDefinition('data_collector.translation')); } - public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() + public static function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() { return [ ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'], diff --git a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 65f047426..9792d2266 100644 --- a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -62,7 +62,7 @@ public function testValidCollector() $this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call } - public function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator + public static function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator { yield [new class() implements TemplateAwareDataCollectorInterface { public function collect(Request $request, Response $response, \Throwable $exception = null) diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index d20f4e7b7..47b66baf3 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -60,7 +60,7 @@ public function testInvalidSessionName($sessionName) ); } - public function getTestInvalidSessionName() + public static function getTestInvalidSessionName() { return [ ['a.b'], @@ -113,7 +113,7 @@ public function testValidAssetsPackageNameConfiguration($packageName) $this->assertArrayHasKey($packageName, $config['assets']['packages']); } - public function provideValidAssetsPackageNameConfigurationTests() + public static function provideValidAssetsPackageNameConfigurationTests() { return [ ['foobar'], @@ -139,7 +139,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess ]); } - public function provideInvalidAssetConfigurationTests() + public static function provideInvalidAssetConfigurationTests() { // helper to turn config into embedded package config $createPackageConfig = function (array $packageConfig) { @@ -192,7 +192,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig) $this->assertEquals($processedConfig, $config['lock']); } - public function provideValidLockConfigurationTests() + public static function provideValidLockConfigurationTests() { yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]]; diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 9abcaf40e..a1c67eef1 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -1751,7 +1751,7 @@ public function testAppRedisTagAwareAdapter(string $configFile) } } - public function appRedisTagAwareConfigProvider(): array + public static function appRedisTagAwareConfigProvider(): array { return [ ['cache_app_redis_tag_aware'], @@ -1930,7 +1930,7 @@ public function testHttpClientFullDefaultOptions() ], $defaultOptions['peer_fingerprint']); } - public function provideMailer(): array + public static function provideMailer(): array { return [ ['mailer_with_dsn', ['main' => 'smtp://example.com']], diff --git a/Tests/Functional/AnnotatedControllerTest.php b/Tests/Functional/AnnotatedControllerTest.php index 20d3609c1..e8641eac8 100644 --- a/Tests/Functional/AnnotatedControllerTest.php +++ b/Tests/Functional/AnnotatedControllerTest.php @@ -29,7 +29,7 @@ public function testAnnotatedController($path, $expectedValue) $this->assertSame('/annotated/create-transaction', $router->generate('symfony_framework_tests_functional_test_annotated_createtransaction')); } - public function getRoutes() + public static function getRoutes() { return [ ['/null_request', 'Symfony\Component\HttpFoundation\Request'], diff --git a/Tests/Functional/ConfigDebugCommandTest.php b/Tests/Functional/ConfigDebugCommandTest.php index 463318af3..11afd0d8a 100644 --- a/Tests/Functional/ConfigDebugCommandTest.php +++ b/Tests/Functional/ConfigDebugCommandTest.php @@ -138,7 +138,7 @@ public function testComplete(array $input, array $expectedSuggestions) } } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'name' => [[''], ['default_config_test', 'extension_without_config_test', 'framework', 'test']]; diff --git a/Tests/Functional/ConfigDumpReferenceCommandTest.php b/Tests/Functional/ConfigDumpReferenceCommandTest.php index 4747b785f..e944960ae 100644 --- a/Tests/Functional/ConfigDumpReferenceCommandTest.php +++ b/Tests/Functional/ConfigDumpReferenceCommandTest.php @@ -103,7 +103,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'name' => [[''], ['DefaultConfigTestBundle', 'default_config_test', 'ExtensionWithoutConfigTestBundle', 'extension_without_config_test', 'FrameworkBundle', 'framework', 'TestBundle', 'test']]; yield 'option --format' => [['--format', ''], ['yaml', 'xml']]; diff --git a/Tests/Functional/ContainerDebugCommandTest.php b/Tests/Functional/ContainerDebugCommandTest.php index ee56012d3..63c717b7b 100644 --- a/Tests/Functional/ContainerDebugCommandTest.php +++ b/Tests/Functional/ContainerDebugCommandTest.php @@ -204,7 +204,7 @@ public function testGetDeprecationNoFile() $this->assertStringContainsString('[WARNING] The deprecation file does not exist', $tester->getDisplay()); } - public function provideIgnoreBackslashWhenFindingService() + public static function provideIgnoreBackslashWhenFindingService() { return [ [BackslashClass::class], @@ -232,7 +232,7 @@ public function testComplete(array $input, array $expectedSuggestions, array $no } } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { $serviceId = 'console.command.container_debug'; $hiddenServiceId = '.console.command.container_debug.lazy'; diff --git a/Tests/Functional/DebugAutowiringCommandTest.php b/Tests/Functional/DebugAutowiringCommandTest.php index c3110cc71..345589c1b 100644 --- a/Tests/Functional/DebugAutowiringCommandTest.php +++ b/Tests/Functional/DebugAutowiringCommandTest.php @@ -129,7 +129,7 @@ public function testComplete(array $input, array $expectedSuggestions) } } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'search' => [[''], ['SessionHandlerInterface', 'Psr\\Log\\LoggerInterface', 'Psr\\Container\\ContainerInterface $parameterBag']]; } diff --git a/Tests/Functional/FragmentTest.php b/Tests/Functional/FragmentTest.php index b514ed3b8..6d8966a17 100644 --- a/Tests/Functional/FragmentTest.php +++ b/Tests/Functional/FragmentTest.php @@ -37,7 +37,7 @@ public function testFragment($insulate) , $client->getResponse()->getContent()); } - public function getConfigs() + public static function getConfigs() { return [ [false], diff --git a/Tests/Functional/ProfilerTest.php b/Tests/Functional/ProfilerTest.php index 7b65ca5c2..d78259795 100644 --- a/Tests/Functional/ProfilerTest.php +++ b/Tests/Functional/ProfilerTest.php @@ -57,7 +57,7 @@ public function testProfilerCollectParameter($insulate) $this->assertNull($client->getProfile()); } - public function getConfigs() + public static function getConfigs() { return [ [false], diff --git a/Tests/Functional/RouterDebugCommandTest.php b/Tests/Functional/RouterDebugCommandTest.php index 82e6bf8bb..6b8eb6b7f 100644 --- a/Tests/Functional/RouterDebugCommandTest.php +++ b/Tests/Functional/RouterDebugCommandTest.php @@ -100,7 +100,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/Tests/Functional/SecurityTest.php b/Tests/Functional/SecurityTest.php index d97039562..c26fa717d 100644 --- a/Tests/Functional/SecurityTest.php +++ b/Tests/Functional/SecurityTest.php @@ -33,7 +33,7 @@ public function testLoginUser(string $username, array $roles, ?string $firewallC $this->assertEquals('Welcome '.$username.'!', $client->getResponse()->getContent()); } - public function getUsers() + public static function getUsers() { yield ['the-username', ['ROLE_FOO'], null]; yield ['the-username', ['ROLE_FOO'], 'main']; diff --git a/Tests/Functional/SerializerTest.php b/Tests/Functional/SerializerTest.php index aaf6ad49c..9a6527b14 100644 --- a/Tests/Functional/SerializerTest.php +++ b/Tests/Functional/SerializerTest.php @@ -52,7 +52,7 @@ public function testNormalizersAndEncodersUseDefaultContextConfigOption(string $ self::assertEquals('foo', $defaultContext['fake_context_option']); } - public function provideNormalizersAndEncodersWithDefaultContextOption(): array + public static function provideNormalizersAndEncodersWithDefaultContextOption(): array { return [ ['serializer.normalizer.constraint_violation_list.alias'], diff --git a/Tests/Functional/SessionTest.php b/Tests/Functional/SessionTest.php index 7d66ff172..dbac7e2f6 100644 --- a/Tests/Functional/SessionTest.php +++ b/Tests/Functional/SessionTest.php @@ -194,7 +194,7 @@ public function testCorrectCacheControlHeadersForCacheableAction($config, $insul $this->assertSame('public, s-maxage=100', $response->headers->get('cache-control')); } - public function getConfigs() + public static function getConfigs() { return [ // configfile, insulate diff --git a/Tests/Routing/RouterTest.php b/Tests/Routing/RouterTest.php index cdcaa490a..d8ad6e2cf 100644 --- a/Tests/Routing/RouterTest.php +++ b/Tests/Routing/RouterTest.php @@ -511,7 +511,7 @@ public function testBooleanContainerParametersWithinRouteCondition() $this->assertSame('1 or 0', $route->getCondition()); } - public function getNonStringValues() + public static function getNonStringValues() { return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]]; } @@ -591,7 +591,7 @@ public function testResolvingMethods() $this->assertEquals(['GET', 'POST'], $route->getMethods()); } - public function getContainerParameterForRoute() + public static function getContainerParameterForRoute() { yield 'String' => ['"foo"']; yield 'Integer' => [0]; diff --git a/Tests/Translation/TranslatorTest.php b/Tests/Translation/TranslatorTest.php index 8698de198..583ebbb77 100644 --- a/Tests/Translation/TranslatorTest.php +++ b/Tests/Translation/TranslatorTest.php @@ -177,7 +177,7 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e $translator->trans('some_message', [], null, 'some_locale'); } - public function getDebugModeAndCacheDirCombinations() + public static function getDebugModeAndCacheDirCombinations() { return [ [false, false], From 161472265836bc3e975d845c65bd5cebf1502415 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 16 Feb 2023 10:33:00 +0100 Subject: [PATCH 07/21] CS fix --- Command/ConfigDebugCommand.php | 4 ++-- Tests/Functional/CachePoolsTest.php | 2 ++ Tests/Functional/SessionTest.php | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Command/ConfigDebugCommand.php b/Command/ConfigDebugCommand.php index 12e501baa..fe4b83a9b 100644 --- a/Command/ConfigDebugCommand.php +++ b/Command/ConfigDebugCommand.php @@ -139,9 +139,9 @@ private function compileContainer(): ContainerBuilder /** * Iterate over configuration until the last step of the given path. * - * @throws LogicException If the configuration does not exist - * * @return mixed + * + * @throws LogicException If the configuration does not exist */ private function getConfigForPath(array $config, string $path, string $alias) { diff --git a/Tests/Functional/CachePoolsTest.php b/Tests/Functional/CachePoolsTest.php index 2bebd2d77..260896658 100644 --- a/Tests/Functional/CachePoolsTest.php +++ b/Tests/Functional/CachePoolsTest.php @@ -26,6 +26,7 @@ public function testCachePools() /** * @requires extension redis + * * @group integration */ public function testRedisCachePools() @@ -49,6 +50,7 @@ public function testRedisCachePools() /** * @requires extension redis + * * @group integration */ public function testRedisCustomCachePools() diff --git a/Tests/Functional/SessionTest.php b/Tests/Functional/SessionTest.php index dbac7e2f6..6ec96bafe 100644 --- a/Tests/Functional/SessionTest.php +++ b/Tests/Functional/SessionTest.php @@ -77,6 +77,7 @@ public function testFlash($config, $insulate) * Tests flash messages work when flashbag service is injected to the constructor. * * @group legacy + * * @dataProvider getConfigs */ public function testFlashOnInjectedFlashbag($config, $insulate) @@ -101,6 +102,7 @@ public function testFlashOnInjectedFlashbag($config, $insulate) /** * @group legacy + * * @dataProvider getConfigs */ public function testSessionServiceTriggerDeprecation($config, $insulate) From 87623353dea3044c9d34382ffc4c5729cf676c90 Mon Sep 17 00:00:00 2001 From: Robert Worgul Date: Wed, 22 Feb 2023 12:10:06 +0100 Subject: [PATCH 08/21] [FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes Fix AbstractController::denyAccessUnlessGranted() for attributes that aren't string or array. Always wrap the given single attribute into an array to not break the parameter type of AccessDeniedException#setAttributes() (which supports strings only for convenience). --- Controller/AbstractController.php | 2 +- Tests/Controller/AbstractControllerTest.php | 34 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Controller/AbstractController.php b/Controller/AbstractController.php index f6eff3f61..85220f1b5 100644 --- a/Controller/AbstractController.php +++ b/Controller/AbstractController.php @@ -239,7 +239,7 @@ protected function denyAccessUnlessGranted($attribute, $subject = null, string $ { if (!$this->isGranted($attribute, $subject)) { $exception = $this->createAccessDeniedException($message); - $exception->setAttributes($attribute); + $exception->setAttributes([$attribute]); $exception->setSubject($subject); throw $exception; diff --git a/Tests/Controller/AbstractControllerTest.php b/Tests/Controller/AbstractControllerTest.php index 9a5c5510c..d8dc199d8 100644 --- a/Tests/Controller/AbstractControllerTest.php +++ b/Tests/Controller/AbstractControllerTest.php @@ -387,6 +387,40 @@ public function testdenyAccessUnlessGranted() $controller->denyAccessUnlessGranted('foo'); } + /** + * @dataProvider provideDenyAccessUnlessGrantedSetsAttributesAsArray + */ + public function testdenyAccessUnlessGrantedSetsAttributesAsArray($attribute, $exceptionAttributes) + { + $authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); + $authorizationChecker->method('isGranted')->willReturn(false); + + $container = new Container(); + $container->set('security.authorization_checker', $authorizationChecker); + + $controller = $this->createController(); + $controller->setContainer($container); + + try { + $controller->denyAccessUnlessGranted($attribute); + $this->fail('there was no exception to check'); + } catch (AccessDeniedException $e) { + $this->assertSame($exceptionAttributes, $e->getAttributes()); + } + } + + public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray() + { + $obj = new \stdClass(); + $obj->foo = 'bar'; + + return [ + 'string attribute' => ['foo', ['foo']], + 'array attribute' => [[1, 3, 3, 7], [[1, 3, 3, 7]]], + 'object attribute' => [$obj, [$obj]], + ]; + } + public function testRenderViewTwig() { $twig = $this->createMock(Environment::class); From 71baf6bc31daa7875ac46abac4a7227412fc1ffb Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 6 Mar 2023 21:48:01 +0100 Subject: [PATCH 09/21] [Tests] Replace `setMethods()` by `onlyMethods()` and `addMethods()` --- Tests/CacheWarmer/AnnotationsCacheWarmerTest.php | 2 +- Tests/CacheWarmer/RouterCacheWarmerTest.php | 8 ++++---- Tests/KernelBrowserTest.php | 2 +- Tests/Routing/RouterTest.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index 806cf46b8..eaee983b1 100644 --- a/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -136,7 +136,7 @@ public function testWarmupRemoveCacheMisses() $cacheFile = tempnam($this->cacheDir, __FUNCTION__); $warmer = $this->getMockBuilder(AnnotationsCacheWarmer::class) ->setConstructorArgs([new AnnotationReader(), $cacheFile]) - ->setMethods(['doWarmUp']) + ->onlyMethods(['doWarmUp']) ->getMock(); $warmer->method('doWarmUp')->willReturnCallback(function ($cacheDir, ArrayAdapter $arrayAdapter) { diff --git a/Tests/CacheWarmer/RouterCacheWarmerTest.php b/Tests/CacheWarmer/RouterCacheWarmerTest.php index 61214b039..727b566e1 100644 --- a/Tests/CacheWarmer/RouterCacheWarmerTest.php +++ b/Tests/CacheWarmer/RouterCacheWarmerTest.php @@ -21,9 +21,9 @@ class RouterCacheWarmerTest extends TestCase { public function testWarmUpWithWarmebleInterface() { - $containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(['get', 'has'])->getMock(); + $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); - $routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->setMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock(); + $routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock(); $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); $routerCacheWarmer = new RouterCacheWarmer($containerMock); @@ -34,9 +34,9 @@ public function testWarmUpWithWarmebleInterface() public function testWarmUpWithoutWarmebleInterface() { - $containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(['get', 'has'])->getMock(); + $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); - $routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->setMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock(); + $routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock(); $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); $routerCacheWarmer = new RouterCacheWarmer($containerMock); $this->expectException(\LogicException::class); diff --git a/Tests/KernelBrowserTest.php b/Tests/KernelBrowserTest.php index 404a239b5..1e462f7d0 100644 --- a/Tests/KernelBrowserTest.php +++ b/Tests/KernelBrowserTest.php @@ -64,7 +64,7 @@ public function testRequestAfterKernelShutdownAndPerformedRequest() private function getKernelMock() { $mock = $this->getMockBuilder($this->getKernelClass()) - ->setMethods(['shutdown', 'boot', 'handle', 'getContainer']) + ->onlyMethods(['shutdown', 'boot', 'handle', 'getContainer']) ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/Routing/RouterTest.php b/Tests/Routing/RouterTest.php index d8ad6e2cf..2cebebed1 100644 --- a/Tests/Routing/RouterTest.php +++ b/Tests/Routing/RouterTest.php @@ -609,7 +609,7 @@ private function getServiceContainer(RouteCollection $routes): Container ->willReturn($routes) ; - $sc = $this->getMockBuilder(Container::class)->setMethods(['get'])->getMock(); + $sc = $this->getMockBuilder(Container::class)->onlyMethods(['get'])->getMock(); $sc ->expects($this->once()) From ad06a790ddb27d8a89f46ab2d38b438a27ea1d72 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 6 Mar 2023 20:42:33 +0100 Subject: [PATCH 10/21] [Tests] Remove occurrences of `withConsecutive()` --- Tests/Console/ApplicationTest.php | 25 +++++++++++++++++++++---- Tests/Translation/TranslatorTest.php | 23 +++++++++++++---------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Tests/Console/ApplicationTest.php b/Tests/Console/ApplicationTest.php index d075ad75f..83c8553b2 100644 --- a/Tests/Console/ApplicationTest.php +++ b/Tests/Console/ApplicationTest.php @@ -258,14 +258,31 @@ private function getKernel(array $bundles, $useDispatcher = false) $container ->expects($this->exactly(2)) ->method('hasParameter') - ->withConsecutive(['console.command.ids'], ['console.lazy_command.ids']) - ->willReturnOnConsecutiveCalls(true, true) + ->willReturnCallback(function (...$args) { + static $series = [ + ['console.command.ids'], + ['console.lazy_command.ids'], + ]; + + $this->assertSame(array_shift($series), $args); + + return true; + }) ; + $container ->expects($this->exactly(2)) ->method('getParameter') - ->withConsecutive(['console.lazy_command.ids'], ['console.command.ids']) - ->willReturnOnConsecutiveCalls([], []) + ->willReturnCallback(function (...$args) { + static $series = [ + ['console.lazy_command.ids'], + ['console.command.ids'], + ]; + + $this->assertSame(array_shift($series), $args); + + return []; + }) ; $kernel = $this->createMock(KernelInterface::class); diff --git a/Tests/Translation/TranslatorTest.php b/Tests/Translation/TranslatorTest.php index 583ebbb77..dc00ef99e 100644 --- a/Tests/Translation/TranslatorTest.php +++ b/Tests/Translation/TranslatorTest.php @@ -148,18 +148,21 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e $loader = $this->createMock(LoaderInterface::class); + $series = [ + /* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */ + [['messages.some_locale.loader', 'some_locale', 'messages'], $someCatalogue], + /* This resource is added by an addResource() call and shall be loaded after the resource_files */ + [['second_resource.some_locale.loader', 'some_locale', 'messages'], $someCatalogue], + ]; + $loader->expects($this->exactly(2)) ->method('load') - ->withConsecutive( - /* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */ - ['messages.some_locale.loader', 'some_locale', 'messages'], - /* This resource is added by an addResource() call and shall be loaded after the resource_files */ - ['second_resource.some_locale.loader', 'some_locale', 'messages'] - ) - ->willReturnOnConsecutiveCalls( - $someCatalogue, - $someCatalogue - ); + ->willReturnCallback(function (...$args) use (&$series) { + [$expectedArgs, $return] = array_shift($series); + $this->assertSame($expectedArgs, $args); + + return $return; + }); $options = [ 'resource_files' => ['some_locale' => ['messages.some_locale.loader']], From eee1a71a929b16bd3601a64cd8d041bf6e6e9691 Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Mon, 13 Mar 2023 16:17:20 +0100 Subject: [PATCH 11/21] =?UTF-8?q?[FrameworkBundle]=20Rename=20limiter?= =?UTF-8?q?=E2=80=99s=20`strategy`=20to=20`policy`=20in=20XSD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/config/schema/symfony-1.0.xsd | 2 +- .../Fixtures/xml/rate_limiter.xml | 19 +++++++++++++++++++ .../XmlFrameworkExtensionTest.php | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml diff --git a/Resources/config/schema/symfony-1.0.xsd b/Resources/config/schema/symfony-1.0.xsd index d4be9fb6f..4366cab50 100644 --- a/Resources/config/schema/symfony-1.0.xsd +++ b/Resources/config/schema/symfony-1.0.xsd @@ -748,7 +748,7 @@ - + diff --git a/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml b/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml new file mode 100644 index 000000000..35488c853 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 944e19709..4a2ff788b 100644 --- a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\RateLimiter\Policy\SlidingWindowLimiter; class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase { @@ -66,4 +67,11 @@ public function testLegacyExceptionsConfig() 'status_code' => 500, ], $configuration[\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class]); } + + public function testRateLimiter() + { + $container = $this->createContainerFromFile('rate_limiter'); + + $this->assertTrue($container->hasDefinition('limiter.sliding_window')); + } } From 913637a5c8e8bea00559eeba03261d64ae250827 Mon Sep 17 00:00:00 2001 From: "A. Pauly" Date: Tue, 14 Mar 2023 17:08:31 +0100 Subject: [PATCH 12/21] [FrameworkBundle] Workflow - Fix LogicException about a wrong configuration of "enabled" node --- DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c70a07635..e9b95db35 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -350,7 +350,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) foreach ($workflows as $key => $workflow) { if (isset($workflow['enabled']) && false === $workflow['enabled']) { - throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.', $workflow['name'])); + throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.', $key)); } unset($workflows[$key]['enabled']); From 8fc6a7831879a691f2159b83ac640964f6c0795d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 17 Mar 2023 09:38:42 +0100 Subject: [PATCH 13/21] explicitly set the HTTP method override option to false --- Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml b/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml index 35488c853..cce1f6799 100644 --- a/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml +++ b/Tests/DependencyInjection/Fixtures/xml/rate_limiter.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + Date: Mon, 20 Mar 2023 11:45:02 +0100 Subject: [PATCH 14/21] [FrameworkBundle] Fix wiring session.handler when handler_id is null --- DependencyInjection/FrameworkExtension.php | 12 ++---------- Resources/config/session.php | 5 +++++ .../FrameworkExtensionTestCase.php | 10 ++++------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 00412e5c6..a3fed9a85 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -1178,16 +1178,8 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c // session handler (the internal callback registered with PHP session management) if (null === $config['handler_id']) { - // Set the handler class to be null - if ($container->hasDefinition('session.storage.native')) { - $container->getDefinition('session.storage.native')->replaceArgument(1, null); - $container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null); - } else { - $container->getDefinition('session.storage.factory.native')->replaceArgument(1, null); - $container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(0, null); - } - - $container->setAlias('session.handler', 'session.handler.native_file'); + $config['save_path'] = null; + $container->setAlias('session.handler', 'session.handler.native'); } else { $container->resolveEnvPlaceholders($config['handler_id'], null, $usedEnvs); diff --git a/Resources/config/session.php b/Resources/config/session.php index 43c0000dd..a26182e93 100644 --- a/Resources/config/session.php +++ b/Resources/config/session.php @@ -133,6 +133,11 @@ ]) ->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "session.storage.factory.mock_file" instead.') + ->set('session.handler.native', StrictSessionHandler::class) + ->args([ + inline_service(\SessionHandler::class), + ]) + ->set('session.handler.native_file', StrictSessionHandler::class) ->args([ inline_service(NativeFileSessionHandler::class) diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index a1c67eef1..3288e96aa 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -648,9 +648,8 @@ public function testNullSessionHandler() $container = $this->createContainerFromFile('session'); $this->assertTrue($container->hasAlias(SessionInterface::class), '->registerSessionConfiguration() loads session.xml'); - $this->assertNull($container->getDefinition('session.storage.factory.native')->getArgument(1)); - $this->assertNull($container->getDefinition('session.storage.factory.php_bridge')->getArgument(0)); - $this->assertSame('session.handler.native_file', (string) $container->getAlias('session.handler')); + $this->assertNull($container->getParameter('session.save_path')); + $this->assertSame('session.handler.native', (string) $container->getAlias('session.handler')); $expected = ['session_factory', 'session', 'initialized_session', 'logger', 'session_collector']; $this->assertEquals($expected, array_keys($container->getDefinition('session_listener')->getArgument(0)->getValues())); @@ -667,9 +666,8 @@ public function testNullSessionHandlerLegacy() $container = $this->createContainerFromFile('session_legacy'); $this->assertTrue($container->hasAlias(SessionInterface::class), '->registerSessionConfiguration() loads session.xml'); - $this->assertNull($container->getDefinition('session.storage.native')->getArgument(1)); - $this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0)); - $this->assertSame('session.handler.native_file', (string) $container->getAlias('session.handler')); + $this->assertNull($container->getParameter('session.save_path')); + $this->assertSame('session.handler.native', (string) $container->getAlias('session.handler')); $expected = ['session_factory', 'session', 'initialized_session', 'logger', 'session_collector']; $this->assertEquals($expected, array_keys($container->getDefinition('session_listener')->getArgument(0)->getValues())); From 2f18651175e7cd0c67f110e64af6e3805a985441 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Feb 2023 16:02:53 +0100 Subject: [PATCH 15/21] [FrameworkBundle] Improve documentation about translation:extract --sort option The `--sort` option only works with `--dump-messages` (i.e. not with `--force`). It took me some time to realize that, and the documentation didn't help me since it was showing an example that didn't work. Contribute to https://github.com/symfony/symfony/issues/37918 --- Command/TranslationUpdateCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Command/TranslationUpdateCommand.php b/Command/TranslationUpdateCommand.php index f0e1dc887..7adc0b4bb 100644 --- a/Command/TranslationUpdateCommand.php +++ b/Command/TranslationUpdateCommand.php @@ -93,7 +93,7 @@ protected function configure() new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'), new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version (deprecated)'), - new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'), + new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically (only works with --dump-messages)', 'asc'), new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'), ]) ->setDescription(self::$defaultDescription) @@ -123,7 +123,6 @@ protected function configure() You can dump a tree-like structure using the yaml format with --as-tree flag: php %command.full_name% --force --format=yaml --as-tree=3 en AcmeBundle - php %command.full_name% --force --format=yaml --sort=asc --as-tree=3 fr EOF ) From 1294218eb885233ce06a89e7529ed256045e5740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rokas=20Mikalk=C4=97nas?= Date: Tue, 28 Mar 2023 12:32:52 +0300 Subject: [PATCH 16/21] [FrameworkBundle] Add missing monolog channel tag for messenger services --- Resources/config/messenger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/messenger.php b/Resources/config/messenger.php index 813d50300..b5d257cbb 100644 --- a/Resources/config/messenger.php +++ b/Resources/config/messenger.php @@ -140,6 +140,7 @@ ->args([ service('logger')->ignoreOnInvalid(), ]) + ->tag('monolog.logger', ['channel' => 'messenger']) ->set('messenger.transport.beanstalkd.factory', BeanstalkdTransportFactory::class) @@ -197,6 +198,7 @@ service('logger')->ignoreOnInvalid(), ]) ->tag('kernel.event_subscriber') + ->tag('monolog.logger', ['channel' => 'messenger']) ->set('messenger.listener.stop_worker_on_stop_exception_listener', StopWorkerOnCustomStopExceptionListener::class) ->tag('kernel.event_subscriber') From 23add729e1ea1913d4a8234a8e23a0b698331cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rokas=20Mikalk=C4=97nas?= Date: Tue, 28 Mar 2023 18:04:16 +0300 Subject: [PATCH 17/21] [FrameworkBundle] Fix services usages output for text descriptor --- Console/Descriptor/TextDescriptor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Console/Descriptor/TextDescriptor.php b/Console/Descriptor/TextDescriptor.php index 4217a43b1..e589f7b34 100644 --- a/Console/Descriptor/TextDescriptor.php +++ b/Console/Descriptor/TextDescriptor.php @@ -361,7 +361,7 @@ protected function describeContainerDefinition(Definition $definition, array $op } $inEdges = null !== $builder && isset($options['id']) ? $this->getServiceEdges($builder, $options['id']) : []; - $tableRows[] = ['Usages', $inEdges ? implode(', ', $inEdges) : 'none']; + $tableRows[] = ['Usages', $inEdges ? implode(\PHP_EOL, $inEdges) : 'none']; $options['output']->table($tableHeaders, $tableRows); } From 0563093973d59c111545d137fe1864c78649485a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 28 Mar 2023 17:33:18 +0200 Subject: [PATCH 18/21] [FrameworkBundle] Fix auto-discovering validator constraints --- Command/DebugAutowiringCommand.php | 3 +++ Resources/config/validator.php | 24 ++++++++++++------------ composer.json | 6 +++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Command/DebugAutowiringCommand.php b/Command/DebugAutowiringCommand.php index 8e5395c7a..7ac33243b 100644 --- a/Command/DebugAutowiringCommand.php +++ b/Command/DebugAutowiringCommand.php @@ -100,6 +100,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $previousId = '-'; $serviceIdsNb = 0; foreach ($serviceIds as $serviceId) { + if ($builder->hasDefinition($serviceId) && $builder->getDefinition($serviceId)->hasTag('container.excluded')) { + continue; + } $text = []; $resolvedServiceId = $serviceId; if (!str_starts_with($serviceId, $previousId)) { diff --git a/Resources/config/validator.php b/Resources/config/validator.php index c397e73d4..63c6e928b 100644 --- a/Resources/config/validator.php +++ b/Resources/config/validator.php @@ -28,6 +28,8 @@ $container->parameters() ->set('validator.mapping.cache.file', param('kernel.cache_dir').'/validation.php'); + $validatorsDir = \dirname((new \ReflectionClass(WhenValidator::class))->getFileName()); + $container->services() ->set('validator', ValidatorInterface::class) ->factory([service('validator.builder'), 'getValidator']) @@ -65,11 +67,15 @@ abstract_arg('Constraint validators locator'), ]) + ->load('Symfony\Component\Validator\Constraints\\', $validatorsDir.'/*Validator.php') + ->exclude($validatorsDir.'/ExpressionLanguageSyntaxValidator.php') + ->abstract() + ->tag('container.excluded') + ->tag('validator.constraint_validator') + ->set('validator.expression', ExpressionValidator::class) ->args([service('validator.expression_language')->nullOnInvalid()]) - ->tag('validator.constraint_validator', [ - 'alias' => 'validator.expression', - ]) + ->tag('validator.constraint_validator') ->set('validator.expression_language', ExpressionLanguage::class) ->args([service('cache.validator_expression_language')->nullOnInvalid()]) @@ -82,9 +88,7 @@ ->args([ abstract_arg('Default mode'), ]) - ->tag('validator.constraint_validator', [ - 'alias' => EmailValidator::class, - ]) + ->tag('validator.constraint_validator') ->set('validator.not_compromised_password', NotCompromisedPasswordValidator::class) ->args([ @@ -92,15 +96,11 @@ param('kernel.charset'), false, ]) - ->tag('validator.constraint_validator', [ - 'alias' => NotCompromisedPasswordValidator::class, - ]) + ->tag('validator.constraint_validator') ->set('validator.when', WhenValidator::class) ->args([service('validator.expression_language')->nullOnInvalid()]) - ->tag('validator.constraint_validator', [ - 'alias' => WhenValidator::class, - ]) + ->tag('validator.constraint_validator') ->set('validator.property_info_loader', PropertyInfoLoader::class) ->args([ diff --git a/composer.json b/composer.json index c7d3685f8..4fc22ab71 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-xml": "*", "symfony/cache": "^5.4|^6.0", "symfony/config": "^6.1", - "symfony/dependency-injection": "^6.2", + "symfony/dependency-injection": "^6.2.8", "symfony/deprecation-contracts": "^2.1|^3", "symfony/error-handler": "^6.1", "symfony/event-dispatcher": "^5.4|^6.0", @@ -58,7 +58,7 @@ "symfony/serializer": "^6.1", "symfony/stopwatch": "^5.4|^6.0", "symfony/string": "^5.4|^6.0", - "symfony/translation": "^5.4|^6.0", + "symfony/translation": "^6.2.8", "symfony/twig-bundle": "^5.4|^6.0", "symfony/validator": "^5.4|^6.0", "symfony/workflow": "^5.4|^6.0", @@ -91,7 +91,7 @@ "symfony/security-csrf": "<5.4", "symfony/security-core": "<5.4", "symfony/stopwatch": "<5.4", - "symfony/translation": "<5.4", + "symfony/translation": "<6.2.8", "symfony/twig-bridge": "<5.4", "symfony/twig-bundle": "<5.4", "symfony/validator": "<5.4", From bef71749c4717beae1adb6677a5b44aad7877e6e Mon Sep 17 00:00:00 2001 From: Bastien Jaillot Date: Mon, 13 Mar 2023 21:59:14 +0100 Subject: [PATCH 19/21] [FrameworkBundle] enable metadata cache when annotation is disabled --- DependencyInjection/FrameworkExtension.php | 6 +++--- .../serializer_mapping_without_annotations.php | 14 ++++++++++++++ .../serializer_mapping_without_annotations.xml | 16 ++++++++++++++++ .../serializer_mapping_without_annotations.yml | 8 ++++++++ .../FrameworkExtensionTestCase.php | 10 ++++++++-- 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 Tests/DependencyInjection/Fixtures/php/serializer_mapping_without_annotations.php create mode 100644 Tests/DependencyInjection/Fixtures/xml/serializer_mapping_without_annotations.xml create mode 100644 Tests/DependencyInjection/Fixtures/yml/serializer_mapping_without_annotations.yml diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 00412e5c6..949890b44 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -1777,9 +1777,6 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild private function registerSerializerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader) { $loader->load('serializer.php'); - if ($container->getParameter('kernel.debug')) { - $container->removeDefinition('serializer.mapping.cache_class_metadata_factory'); - } $chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); @@ -1805,6 +1802,9 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder if (\PHP_VERSION_ID < 80000 && !$this->annotationsConfigEnabled) { throw new \LogicException('"enable_annotations" on the serializer cannot be set as the PHP version is lower than 8 and Annotations support is disabled. Consider upgrading PHP.'); } + if ($container->getParameter('kernel.debug')) { + $container->removeDefinition('serializer.mapping.cache_class_metadata_factory'); + } $annotationLoader = new Definition( 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', diff --git a/Tests/DependencyInjection/Fixtures/php/serializer_mapping_without_annotations.php b/Tests/DependencyInjection/Fixtures/php/serializer_mapping_without_annotations.php new file mode 100644 index 000000000..4126fd900 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/php/serializer_mapping_without_annotations.php @@ -0,0 +1,14 @@ +loadFromExtension('framework', [ + 'serializer' => [ + 'enable_annotations' => false, + 'mapping' => [ + 'paths' => [ + '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files', + '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml', + '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml', + ], + ], + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/xml/serializer_mapping_without_annotations.xml b/Tests/DependencyInjection/Fixtures/xml/serializer_mapping_without_annotations.xml new file mode 100644 index 000000000..53c4b2f02 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/xml/serializer_mapping_without_annotations.xml @@ -0,0 +1,16 @@ + + + + + + + + %kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files + %kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml + %kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml + + + + diff --git a/Tests/DependencyInjection/Fixtures/yml/serializer_mapping_without_annotations.yml b/Tests/DependencyInjection/Fixtures/yml/serializer_mapping_without_annotations.yml new file mode 100644 index 000000000..e7f5bc4b8 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/yml/serializer_mapping_without_annotations.yml @@ -0,0 +1,8 @@ +framework: + serializer: + enable_annotations: false + mapping: + paths: + - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files" + - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml" + - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml" diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index a1c67eef1..e1ac84630 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -1529,9 +1529,15 @@ public function testSerializerCacheActivated() $this->assertEquals(new Reference('serializer.mapping.cache.symfony'), $cache); } - public function testSerializerCacheNotActivatedDebug() + public function testSerializerCacheUsedWithoutAnnotationsAndMappingFiles() { - $container = $this->createContainerFromFile('serializer_enabled', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]); + $container = $this->createContainerFromFile('serializer_mapping_without_annotations', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]); + $this->assertTrue($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); + } + + public function testSerializerCacheNotActivatedWithAnnotations() + { + $container = $this->createContainerFromFile('serializer_mapping', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); } From df1899b6e9e52fc495daad6b4e307801860a66da Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 1 Apr 2023 13:12:43 +0200 Subject: [PATCH 20/21] [FrameworkBundle] Fix registering ExpressionValidator --- Resources/config/validator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Resources/config/validator.php b/Resources/config/validator.php index ccf6e9ecd..1c896de3a 100644 --- a/Resources/config/validator.php +++ b/Resources/config/validator.php @@ -75,7 +75,9 @@ ->set('validator.expression', ExpressionValidator::class) ->args([service('validator.expression_language')->nullOnInvalid()]) - ->tag('validator.constraint_validator') + ->tag('validator.constraint_validator', [ + 'alias' => 'validator.expression', + ]) ->set('validator.expression_language', ExpressionLanguage::class) ->args([service('cache.validator_expression_language')->nullOnInvalid()]) From 4953b174b80f8ac8b1cb0620382555ba1f2f601c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rokas=20Mikalk=C4=97nas?= Date: Sat, 22 Apr 2023 19:01:14 +0300 Subject: [PATCH 21/21] [FrameworkBundle] Make service edges unique --- Console/Descriptor/Descriptor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Console/Descriptor/Descriptor.php b/Console/Descriptor/Descriptor.php index 64c296e81..09128274d 100644 --- a/Console/Descriptor/Descriptor.php +++ b/Console/Descriptor/Descriptor.php @@ -343,9 +343,9 @@ private function getContainerEnvVars(ContainerBuilder $container): array protected function getServiceEdges(ContainerBuilder $builder, string $serviceId): array { try { - return array_map(function (ServiceReferenceGraphEdge $edge) { + return array_values(array_unique(array_map(function (ServiceReferenceGraphEdge $edge) { return $edge->getSourceNode()->getId(); - }, $builder->getCompiler()->getServiceReferenceGraph()->getNode($serviceId)->getInEdges()); + }, $builder->getCompiler()->getServiceReferenceGraph()->getNode($serviceId)->getInEdges()))); } catch (InvalidArgumentException $exception) { return []; }