From 93a2f96492d13bad773d0f62f17dcb0d2df2d4d1 Mon Sep 17 00:00:00 2001 From: Maxime Pinot Date: Fri, 15 Apr 2022 10:48:25 +0200 Subject: [PATCH 01/60] Remove useless condition --- src/Symfony/Component/Form/FormBuilder.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 37fca950a77c..42020c921eae 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -69,10 +69,6 @@ public function add($child, string $type = null, array $options = []) throw new UnexpectedTypeException($child, 'string or Symfony\Component\Form\FormBuilderInterface'); } - if (null !== $type && !\is_string($type)) { - throw new UnexpectedTypeException($type, 'string or null'); - } - // Add to "children" to maintain order $this->children[$child] = null; $this->unresolvedChildren[$child] = [$type, $options]; From f49cb6a4a2e59e066caf6177b3177b9deb6a3490 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 23 Feb 2022 16:33:13 +0100 Subject: [PATCH 02/60] [Routing] Add Requirement, a collection of universal regular-expression constants to use as route parameter requirements --- src/Symfony/Component/Routing/CHANGELOG.md | 1 + .../Routing/Requirement/Requirement.php | 33 ++ .../Tests/Requirement/RequirementTest.php | 435 ++++++++++++++++++ 3 files changed, 469 insertions(+) create mode 100644 src/Symfony/Component/Routing/Requirement/Requirement.php create mode 100644 src/Symfony/Component/Routing/Tests/Requirement/RequirementTest.php diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index dee13d3a0980..36181ac71600 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -9,6 +9,7 @@ CHANGELOG * Support the `attribute` type (alias of `annotation`) in annotation loaders * Already encoded slashes are not decoded nor double-encoded anymore when generating URLs (query parameters) * Add `EnumRequirement` to help generate route requirements from a `\BackedEnum` + * Add `Requirement`, a collection of universal regular-expression constants to use as route parameter requirements 5.3 --- diff --git a/src/Symfony/Component/Routing/Requirement/Requirement.php b/src/Symfony/Component/Routing/Requirement/Requirement.php new file mode 100644 index 000000000000..aa5e464e7260 --- /dev/null +++ b/src/Symfony/Component/Routing/Requirement/Requirement.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Requirement; + +/* + * A collection of universal regular-expression constants to use as route parameter requirements. + */ +enum Requirement +{ + public const ASCII_SLUG = '[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*'; // symfony/string AsciiSlugger default implementation + public const CATCH_ALL = '.+'; + public const DATE_YMD = '[0-9]{4}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|(? + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests\Requirement; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Routing\Requirement\Requirement; +use Symfony\Component\Routing\Route; + +class RequirementTest extends TestCase +{ + /** + * @testWith ["FOO"] + * ["foo"] + * ["1987"] + * ["42-42"] + * ["fo2o-bar"] + * ["foo-bA198r-Ccc"] + * ["fo10O-bar-CCc-fooba187rccc"] + */ + public function testAsciiSlugOK(string $slug) + { + $this->assertMatchesRegularExpression( + (new Route('/{slug}', [], ['slug' => Requirement::ASCII_SLUG]))->compile()->getRegex(), + '/'.$slug, + ); + } + + /** + * @testWith [""] + * ["-"] + * ["fôo"] + * ["-FOO"] + * ["foo-"] + * ["-foo-"] + * ["-foo-bar-"] + * ["foo--bar"] + */ + public function testAsciiSlugKO(string $slug) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{slug}', [], ['slug' => Requirement::ASCII_SLUG]))->compile()->getRegex(), + '/'.$slug, + ); + } + + /** + * @testWith ["foo"] + * ["foo/bar/ccc"] + * ["///"] + */ + public function testCatchAllOK(string $path) + { + $this->assertMatchesRegularExpression( + (new Route('/{path}', [], ['path' => Requirement::CATCH_ALL]))->compile()->getRegex(), + '/'.$path, + ); + } + + /** + * @testWith [""] + */ + public function testCatchAllKO(string $path) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{path}', [], ['path' => Requirement::CATCH_ALL]))->compile()->getRegex(), + '/'.$path, + ); + } + + /** + * @testWith ["0000-01-01"] + * ["9999-12-31"] + * ["2022-04-15"] + * ["2024-02-29"] + * ["1243-04-31"] + */ + public function testDateYmdOK(string $date) + { + $this->assertMatchesRegularExpression( + (new Route('/{date}', [], ['date' => Requirement::DATE_YMD]))->compile()->getRegex(), + '/'.$date, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["0000-01-00"] + * ["9999-00-31"] + * ["2022-02-30"] + * ["2022-02-31"] + */ + public function testDateYmdKO(string $date) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{date}', [], ['date' => Requirement::DATE_YMD]))->compile()->getRegex(), + '/'.$date, + ); + } + + /** + * @testWith ["0"] + * ["1"] + * ["42"] + * ["42198"] + * ["999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"] + */ + public function testDigitsOK(string $digits) + { + $this->assertMatchesRegularExpression( + (new Route('/{digits}', [], ['digits' => Requirement::DIGITS]))->compile()->getRegex(), + '/'.$digits, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["-1"] + * ["3.14"] + */ + public function testDigitsKO(string $digits) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{digits}', [], ['digits' => Requirement::DIGITS]))->compile()->getRegex(), + '/'.$digits, + ); + } + + /** + * @testWith ["00000000000000000000000000"] + * ["ZZZZZZZZZZZZZZZZZZZZZZZZZZ"] + * ["01G0P4XH09KW3RCF7G4Q57ESN0"] + * ["05CSACM1MS9RB9H5F61BYA146Q"] + */ + public function testUidBase32OK(string $uid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_BASE32]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["01G0P4XH09KW3RCF7G4Q57ESN"] + * ["01G0P4XH09KW3RCF7G4Q57ESNU"] + */ + public function testUidBase32KO(string $uid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_BASE32]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith ["1111111111111111111111"] + * ["zzzzzzzzzzzzzzzzzzzzzz"] + * ["1BkPBX6T19U8TUAjBTtgwH"] + * ["1fg491dt8eQpf2TU42o2bY"] + */ + public function testUidBase58OK(string $uid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_BASE58]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["1BkPBX6T19U8TUAjBTtgw"] + * ["1BkPBX6T19U8TUAjBTtgwI"] + */ + public function testUidBase58KO(string $uid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_BASE58]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith ["00000000-0000-0000-0000-000000000000"] + * ["ffffffff-ffff-ffff-ffff-ffffffffffff"] + * ["01802c4e-c409-9f07-863c-f025ca7766a0"] + * ["056654ca-0699-4e16-9895-e60afca090d7"] + */ + public function testUidRfc4122OK(string $uid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_RFC4122]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["01802c4e-c409-9f07-863c-f025ca7766a"] + * ["01802c4e-c409-9f07-863c-f025ca7766ag"] + * ["01802c4ec4099f07863cf025ca7766a0"] + */ + public function testUidRfc4122KO(string $uid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uid}', [], ['uid' => Requirement::UID_RFC4122]))->compile()->getRegex(), + '/'.$uid, + ); + } + + /** + * @testWith ["00000000000000000000000000"] + * ["7ZZZZZZZZZZZZZZZZZZZZZZZZZ"] + * ["01G0P4ZPM69QTD4MM4ENAEA4EW"] + */ + public function testUlidOK(string $ulid) + { + $this->assertMatchesRegularExpression( + (new Route('/{ulid}', [], ['ulid' => Requirement::ULID]))->compile()->getRegex(), + '/'.$ulid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["8ZZZZZZZZZZZZZZZZZZZZZZZZZ"] + * ["01G0P4ZPM69QTD4MM4ENAEA4E"] + */ + public function testUlidKO(string $ulid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{ulid}', [], ['ulid' => Requirement::ULID]))->compile()->getRegex(), + '/'.$ulid, + ); + } + + /** + * @testWith ["00000000-0000-1000-8000-000000000000"] + * ["ffffffff-ffff-6fff-bfff-ffffffffffff"] + * ["8c670a1c-bc95-11ec-8422-0242ac120002"] + * ["61c86569-e477-3ed9-9e3b-1562edb03277"] + * ["e55a29be-ba25-46e0-a5e5-85b78a6f9a11"] + * ["bad98960-f1a1-530e-9a82-07d0b6c4e62f"] + * ["1ecbc9a8-432d-6b14-af93-715adc3b830c"] + */ + public function testUuidOK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["01802c74-d78c-b085-0cdf-7cbad87c70a3"] + * ["e55a29be-ba25-46e0-a5e5-85b78a6f9a1"] + * ["e55a29bh-ba25-46e0-a5e5-85b78a6f9a11"] + * ["e55a29beba2546e0a5e585b78a6f9a11"] + */ + public function testUuidKO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith ["00000000-0000-1000-8000-000000000000"] + * ["ffffffff-ffff-1fff-bfff-ffffffffffff"] + * ["21902510-bc96-11ec-8422-0242ac120002"] + * ["a8ff8f60-088e-1099-a09d-53afc49918d1"] + * ["b0ac612c-9117-17a1-901f-53afc49918d1"] + */ + public function testUuidV1OK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V1]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["a3674b89-0170-3e30-8689-52939013e39c"] + * ["e0040090-3cb0-4bf9-a868-407770c964f9"] + * ["2e2b41d9-e08c-53d2-b435-818b9c323942"] + * ["2a37b67a-5eaa-6424-b5d6-ffc9ba0f2a13"] + */ + public function testUuidV1KO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V1]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith ["00000000-0000-3000-8000-000000000000"] + * ["ffffffff-ffff-3fff-bfff-ffffffffffff"] + * ["2b3f1427-33b2-30a9-8759-07355007c204"] + * ["c38e7b09-07f7-3901-843d-970b0186b873"] + */ + public function testUuidV3OK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V3]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["e24d9c0e-bc98-11ec-9924-53afc49918d1"] + * ["1c240248-7d0b-41a4-9d20-61ad2915a58c"] + * ["4816b668-385b-5a65-808d-bca410f45090"] + * ["1d2f3104-dff6-64c6-92ff-0f74b1d0e2af"] + */ + public function testUuidV3KO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V3]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith ["00000000-0000-4000-8000-000000000000"] + * ["ffffffff-ffff-4fff-bfff-ffffffffffff"] + * ["b8f15bf4-46e2-4757-bbce-11ae83f7a6ea"] + * ["eaf51230-1ce2-40f1-ab18-649212b26198"] + */ + public function testUuidV4OK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V4]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["15baaab2-f310-11d2-9ecf-53afc49918d1"] + * ["acd44dc8-d2cc-326c-9e3a-80a3305a25e8"] + * ["7fc2705f-a8a4-5b31-99a8-890686d64189"] + * ["1ecbc991-3552-6920-998e-efad54178a98"] + */ + public function testUuidV4KO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V4]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith ["00000000-0000-5000-8000-000000000000"] + * ["ffffffff-ffff-5fff-bfff-ffffffffffff"] + * ["49f4d32c-28b3-5802-8717-a2896180efbd"] + * ["58b3c62e-a7df-5a82-93a6-fbe5fda681c1"] + */ + public function testUuidV5OK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V5]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["b99ad578-fdd3-1135-9d3b-53afc49918d1"] + * ["b3ee3071-7a2b-3e17-afdf-6b6aec3acf85"] + * ["2ab4f5a7-6412-46c1-b3ab-1fe1ed391e27"] + * ["135fdd3d-e193-653e-865d-67e88cf12e44"] + */ + public function testUuidV5KO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V5]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith ["00000000-0000-6000-8000-000000000000"] + * ["ffffffff-ffff-6fff-bfff-ffffffffffff"] + * ["2c51caad-c72f-66b2-b6d7-8766d36c73df"] + * ["17941ebb-48fa-6bfe-9bbd-43929f8784f5"] + * ["1ecbc993-f6c2-67f2-8fbe-295ed594b344"] + */ + public function testUuidV6OK(string $uuid) + { + $this->assertMatchesRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V6]))->compile()->getRegex(), + '/'.$uuid, + ); + } + + /** + * @testWith [""] + * ["foo"] + * ["821040f4-7b67-12a3-9770-53afc49918d1"] + * ["802dc245-aaaa-3649-98c6-31c549b0df86"] + * ["92d2e5ad-bc4e-4947-a8d9-77706172ca83"] + * ["6e124559-d260-511e-afdc-e57c7025fed0"] + */ + public function testUuidV6KO(string $uuid) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{uuid}', [], ['uuid' => Requirement::UUID_V6]))->compile()->getRegex(), + '/'.$uuid, + ); + } +} From 74e8abd33935098a065501b07c9f93845910a808 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 15 Apr 2022 11:49:59 +0200 Subject: [PATCH 03/60] Don't replace symfony/security-guard --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 0c750c584e9c..f21c4b45ebf7 100644 --- a/composer.json +++ b/composer.json @@ -95,7 +95,6 @@ "symfony/security-bundle": "self.version", "symfony/security-core": "self.version", "symfony/security-csrf": "self.version", - "symfony/security-guard": "self.version", "symfony/security-http": "self.version", "symfony/semaphore": "self.version", "symfony/serializer": "self.version", From 74758711e3b386bd456aafd7c0f4a70ec95b04d0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 15 Apr 2022 12:19:12 +0200 Subject: [PATCH 04/60] [TwigBundle] Deprecate option "autoescape", use "autoescape_service[_method]" instead --- src/Symfony/Bundle/TwigBundle/CHANGELOG.md | 1 + .../Bundle/TwigBundle/DependencyInjection/Configuration.php | 5 ++++- .../Tests/DependencyInjection/Fixtures/php/full.php | 1 - .../Tests/DependencyInjection/Fixtures/xml/extra.xml | 2 +- .../Tests/DependencyInjection/Fixtures/xml/full.xml | 2 +- .../Tests/DependencyInjection/Fixtures/yml/full.yml | 1 - .../Tests/DependencyInjection/TwigExtensionTest.php | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index e082ba6501c3..aaa0ae400f7a 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG --- * Add option `twig.file_name_pattern` to restrict which files are compiled by cache warmer and linter + * Deprecate option `twig.autoescape`, use `twig.autoescape_service[_method]` instead 6.0 --- diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 83654fb4813e..b85a3bf4b195 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -127,7 +127,10 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode) $rootNode ->fixXmlConfig('path') ->children() - ->variableNode('autoescape')->defaultValue('name')->end() + ->variableNode('autoescape') + ->defaultValue('name') + ->setDeprecated('symfony/twig-bundle', '6.1', 'Option "%node%" at "%path%" is deprecated, use autoescape_service[_method] instead.') + ->end() ->scalarNode('autoescape_service')->defaultNull()->end() ->scalarNode('autoescape_service_method')->defaultNull()->end() ->scalarNode('base_template_class')->example('Twig\Template')->cannotBeEmpty()->end() diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 8dd2be40960b..9e7b500795ec 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -11,7 +11,6 @@ 'bad' => ['key' => 'foo'], ], 'auto_reload' => true, - 'autoescape' => true, 'base_template_class' => 'stdClass', 'cache' => '/tmp', 'charset' => 'ISO-8859-1', diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml index 17bcf0acd449..92767e411057 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.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/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + namespaced_path3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 8ece3b80b794..3f7d1de266ec 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.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/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + MyBundle::form.html.twig @@qux diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 24c10c23fe8f..d18672453992 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -7,7 +7,6 @@ twig: pi: 3.14 bad: {key: foo} auto_reload: true - autoescape: true base_template_class: stdClass cache: /tmp charset: ISO-8859-1 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 361e0b8b24d0..cd60cbb7fd9e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -82,7 +82,7 @@ public function testLoadFullConfiguration($format) // Twig options $options = $container->getDefinition('twig')->getArgument(1); $this->assertTrue($options['auto_reload'], '->load() sets the auto_reload option'); - $this->assertTrue($options['autoescape'], '->load() sets the autoescape option'); + $this->assertSame('name', $options['autoescape'], '->load() sets the autoescape option'); $this->assertEquals('stdClass', $options['base_template_class'], '->load() sets the base_template_class option'); $this->assertEquals('/tmp', $options['cache'], '->load() sets the cache option'); $this->assertEquals('ISO-8859-1', $options['charset'], '->load() sets the charset option'); From a38373a1ad0506500a6450d577f03e85f47dc279 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 15 Apr 2022 12:22:14 +0200 Subject: [PATCH 05/60] Bump Symfony version to 6.1.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a7c0eb022d1f..aafc62dbb01f 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.0-BETA1'; + public const VERSION = '6.1.0-DEV'; public const VERSION_ID = 60100; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'BETA1'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From a412f30e7786bc00cd0353800bd80824a772e010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 11 Mar 2022 09:39:49 +0100 Subject: [PATCH 06/60] [SecurityBundle] Use config's secret in remember-me signatures --- .../Security/Factory/RememberMeFactory.php | 7 ++- .../SecurityExtensionTest.php | 43 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index 0ecc6df4ef25..735b08744a0a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -128,6 +128,7 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal $tokenVerifier = $this->createTokenVerifier($container, $firewallName, $config['token_verifier'] ?? null); $container->setDefinition($rememberMeHandlerId, new ChildDefinition('security.authenticator.persistent_remember_me_handler')) ->replaceArgument(0, new Reference($tokenProviderId)) + ->replaceArgument(1, $config['secret']) ->replaceArgument(2, new Reference($userProviderId)) ->replaceArgument(4, $config) ->replaceArgument(6, $tokenVerifier) @@ -136,6 +137,7 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal $signatureHasherId = 'security.authenticator.remember_me_signature_hasher.'.$firewallName; $container->setDefinition($signatureHasherId, new ChildDefinition('security.authenticator.remember_me_signature_hasher')) ->replaceArgument(1, $config['signature_properties']) + ->replaceArgument(2, $config['secret']) ; $container->setDefinition($rememberMeHandlerId, new ChildDefinition('security.authenticator.signature_remember_me_handler')) @@ -205,7 +207,10 @@ public function addConfiguration(NodeDefinition $node) ; $builder - ->scalarNode('secret')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('secret') + ->cannotBeEmpty() + ->defaultValue('%kernel.secret%') + ->end() ->scalarNode('service')->end() ->arrayNode('user_providers') ->beforeNormalization() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 3b69d2a91fe8..684e43e28a50 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -419,7 +419,7 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same 'firewalls' => [ 'default' => [ 'form_login' => null, - 'remember_me' => ['secret' => 'baz'], + 'remember_me' => [], ], ], ]); @@ -433,6 +433,7 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same $this->assertEquals($samesite, $definition->getArgument(3)['samesite']); $this->assertEquals($secure, $definition->getArgument(3)['secure']); + $this->assertSame('%kernel.secret%', $definition->getArgument(1)); } /** @@ -484,6 +485,46 @@ public function testCustomRememberMeHandler() $this->assertEquals([['firewall' => 'default']], $handler->getTag('security.remember_me_handler')); } + public function testSecretRememberMeHasher() + { + $container = $this->getRawContainer(); + + $container->register('custom_remember_me', \stdClass::class); + $container->loadFromExtension('security', [ + 'enable_authenticator_manager' => true, + 'firewalls' => [ + 'default' => [ + 'remember_me' => ['secret' => 'very'], + ], + ], + ]); + + $container->compile(); + + $handler = $container->getDefinition('security.authenticator.remember_me_signature_hasher.default'); + $this->assertSame('very', $handler->getArgument(2)); + } + + public function testSecretRememberMeHandler() + { + $container = $this->getRawContainer(); + + $container->register('custom_remember_me', \stdClass::class); + $container->loadFromExtension('security', [ + 'enable_authenticator_manager' => true, + 'firewalls' => [ + 'default' => [ + 'remember_me' => ['secret' => 'very', 'token_provider' => 'token_provider_id'], + ], + ], + ]); + + $container->compile(); + + $handler = $container->getDefinition('security.authenticator.remember_me_handler.default'); + $this->assertSame('very', $handler->getArgument(1)); + } + public function sessionConfigurationProvider() { return [ From 7db348030442278a826b64ebd09acf1f47b9a376 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 15 Apr 2022 15:57:25 +0200 Subject: [PATCH 07/60] [PasswordHasher] Fix composer.json --- src/Symfony/Component/PasswordHasher/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/PasswordHasher/composer.json b/src/Symfony/Component/PasswordHasher/composer.json index fb41798e1da2..ccea8122a21c 100644 --- a/src/Symfony/Component/PasswordHasher/composer.json +++ b/src/Symfony/Component/PasswordHasher/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "symfony/security-core": "^5.3|^6.0", - "symfony/console": "^5" + "symfony/console": "^5.3|^6.0" }, "conflict": { "symfony/security-core": "<5.3" From 9bbd28b6d4e7e225e5cc774859d833e665003715 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 15 Apr 2022 15:56:01 +0200 Subject: [PATCH 08/60] Clean skippable tests that are never skipped --- .../Form/ChoiceList/ORMQueryBuilderLoaderTest.php | 7 ------- .../Tests/PropertyInfo/DoctrineExtractorTest.php | 8 -------- .../Doctrine/Tests/Validator/DoctrineLoaderTest.php | 8 -------- .../Monolog/Tests/Processor/TokenProcessorTest.php | 4 ---- .../Bridge/Twig/Tests/Command/DebugCommandTest.php | 4 ---- .../Bridge/Twig/Tests/Command/LintCommandTest.php | 4 ---- .../Tests/Extension/HttpFoundationExtensionTest.php | 12 ------------ .../Twig/Tests/Extension/HttpKernelExtensionTest.php | 4 ---- .../Twig/Tests/Extension/WorkflowExtensionTest.php | 10 ---------- .../Tests/DependencyInjection/DebugExtensionTest.php | 4 ---- .../Tests/Controller/AbstractControllerTest.php | 4 ---- .../DependencyInjection/FrameworkExtensionTest.php | 5 ----- .../Tests/Functional/RouterDebugCommandTest.php | 4 ---- .../FrameworkBundle/Tests/Test/WebTestCaseTest.php | 5 ----- .../Compiler/MergeExtensionConfigurationPassTest.php | 5 ----- .../DomCrawler/Tests/Html5ParserCrawlerTest.php | 11 ----------- .../RegisterListenersPassTest.php | 8 -------- .../Form/Tests/Command/DebugCommandTest.php | 4 ---- .../Component/Form/Tests/FormErrorIteratorTest.php | 4 ---- .../Component/HttpFoundation/Tests/UrlHelperTest.php | 4 ---- .../EventListener/DebugHandlersListenerTest.php | 4 ---- .../Security/CheckLdapCredentialsListenerTest.php | 12 ------------ .../Tests/Transport/SendgridApiTransportTest.php | 4 ---- .../Messenger/Tests/Command/DebugCommandTest.php | 4 ---- .../Tests/Command/UserPasswordHashCommandTest.php | 4 ---- .../Tests/Extractor/PhpDocExtractorTest.php | 5 ----- .../Tests/Extractor/SerializerExtractorTest.php | 5 ----- .../Tests/Command/TranslationPullCommandTest.php | 4 ---- .../Tests/Command/TranslationPushCommandTest.php | 4 ---- .../DataCollector/TranslationDataCollectorTest.php | 8 -------- .../Uid/Tests/Command/GenerateUlidCommandTest.php | 4 ---- .../Uid/Tests/Command/GenerateUuidCommandTest.php | 4 ---- .../Tests/Command/ServerDumpCommandTest.php | 4 ---- .../Component/Yaml/Tests/Command/LintCommandTest.php | 8 -------- 34 files changed, 193 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index 7d253dc59b85..efb3b04824b6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -14,7 +14,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\GuidType; use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper; @@ -226,12 +225,6 @@ public function testUidThrowProperException($entityClass) public function testEmbeddedIdentifierName() { - if (Version::compare('2.5.0') > 0) { - $this->markTestSkipped('Applicable only for Doctrine >= 2.5.0'); - - return; - } - $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder(\QueryMock::class) diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index c53a8d3c4dbe..9416c6404847 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -86,10 +86,6 @@ public function testGetProperties() public function testTestGetPropertiesWithEmbedded() { - if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) { - $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); - } - $this->assertEquals( [ 'id', @@ -109,10 +105,6 @@ public function testExtract($property, array $type = null) public function testExtractWithEmbedded() { - if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) { - $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); - } - $expectedTypes = [new Type( Type::BUILTIN_TYPE_OBJECT, false, diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index 027e21e0dd58..23c7e758505a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -27,7 +27,6 @@ use Symfony\Component\Validator\Mapping\AutoMappingStrategy; use Symfony\Component\Validator\Mapping\CascadingStrategy; use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Mapping\Loader\AutoMappingTrait; use Symfony\Component\Validator\Mapping\PropertyMetadata; use Symfony\Component\Validator\Mapping\TraversalStrategy; use Symfony\Component\Validator\Tests\Fixtures\Entity; @@ -38,13 +37,6 @@ */ class DoctrineLoaderTest extends TestCase { - protected function setUp(): void - { - if (!trait_exists(AutoMappingTrait::class)) { - $this->markTestSkipped('Auto-mapping requires symfony/validation 4.4+'); - } - } - public function testLoadClassMetadata() { $validator = Validation::createValidatorBuilder() diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php index c9e37cfdb2c4..249757d562e0 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php @@ -26,10 +26,6 @@ class TokenProcessorTest extends TestCase { public function testProcessor() { - if (!method_exists(UsernamePasswordToken::class, 'getUserIdentifier')) { - $this->markTestSkipped('This test requires symfony/security-core 5.3+'); - } - $token = new UsernamePasswordToken(new InMemoryUser('user', 'password', ['ROLE_USER']), 'provider', ['ROLE_USER']); $tokenStorage = $this->createMock(TokenStorageInterface::class); $tokenStorage->method('getToken')->willReturn($token); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 2488a27677af..f0d7d661b1ff 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -299,10 +299,6 @@ public function testWithFilter() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; $loader = new FilesystemLoader([], $projectDir); $environment = new Environment($loader); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 6a3d640b2d5b..6428f4860ba7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -141,10 +141,6 @@ public function testLintAutodetectsGithubActionEnvironment() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $tester = new CommandCompletionTester($this->createCommand()); $this->assertSame($expectedSuggestions, $tester->complete($input)); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index ea3bb17bb303..131cb3d040a4 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -60,10 +60,6 @@ public function getGenerateAbsoluteUrlData() */ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) { - if (!class_exists(RequestContext::class)) { - $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); - } - $requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path); $extension = new HttpFoundationExtension(new UrlHelper(new RequestStack(), $requestContext)); @@ -75,10 +71,6 @@ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host */ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) { - if (!class_exists(RequestContext::class)) { - $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); - } - $extension = new HttpFoundationExtension(new UrlHelper(new RequestStack())); $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); @@ -118,10 +110,6 @@ public function testGenerateAbsoluteUrlWithScriptFileName() */ public function testGenerateRelativePath($expected, $path, $pathinfo) { - if (!method_exists(Request::class, 'getRelativeUriForPath')) { - $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.'); - } - $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); $extension = new HttpFoundationExtension(new UrlHelper($stack)); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index a3294db0d2ae..ee987d168801 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -58,10 +58,6 @@ public function testUnknownFragmentRenderer() public function testGenerateFragmentUri() { - if (!class_exists(FragmentUriGenerator::class)) { - $this->markTestSkipped('HttpKernel 5.3+ is required'); - } - $requestStack = new RequestStack(); $requestStack->push(Request::create('/')); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php index 23dcc64b3d41..1252efb8d6ee 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php @@ -30,10 +30,6 @@ class WorkflowExtensionTest extends TestCase protected function setUp(): void { - if (!class_exists(Workflow::class)) { - $this->markTestSkipped('The Workflow component is needed to run tests for this extension.'); - } - $places = ['ordered', 'waiting_for_payment', 'processed']; $transitions = [ $this->t1 = new Transition('t1', 'ordered', 'waiting_for_payment'), @@ -110,9 +106,6 @@ public function testGetMarkedPlaces() public function testGetMetadata() { - if (!class_exists(InMemoryMetadataStore::class)) { - $this->markTestSkipped('This test requires symfony/workflow:4.1.'); - } $subject = new Subject(); $this->assertSame('workflow title', $this->extension->getMetadata($subject, 'title')); @@ -124,9 +117,6 @@ public function testGetMetadata() public function testbuildTransitionBlockerList() { - if (!class_exists(TransitionBlockerList::class)) { - $this->markTestSkipped('This test requires symfony/workflow:4.1.'); - } $subject = new Subject(); $list = $this->extension->buildTransitionBlockerList($subject, 't1'); diff --git a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php index 31afae4d93ac..f026d4d18823 100644 --- a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php +++ b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php @@ -43,10 +43,6 @@ public function testLoadWithoutConfiguration() public function testUnsetClosureFileInfoShouldBeRegisteredInVarCloner() { - if (!method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) { - $this->markTestSkipped('Method not available'); - } - $container = $this->createContainer(); $container->registerExtension(new DebugExtension()); $container->loadFromExtension('debug', []); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index f4215d39832d..da6997df578c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -79,10 +79,6 @@ public function testSubscribedServices() public function testGetParameter() { - if (!class_exists(ContainerBag::class)) { - $this->markTestSkipped('ContainerBag class does not exist'); - } - $container = new Container(new FrozenParameterBag(['foo' => 'bar'])); $container->set('parameter_bag', new ContainerBag($container)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e99bd83ba202..0f31cd1931d3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -71,7 +71,6 @@ use Symfony\Component\Translation\DependencyInjection\TranslatorPass; use Symfony\Component\Translation\LocaleSwitcher; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; -use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow; @@ -1298,10 +1297,6 @@ public function testValidationMapping() public function testValidationAutoMapping() { - if (!class_exists(PropertyInfoLoader::class)) { - $this->markTestSkipped('Auto-mapping requires symfony/validation 4.2+'); - } - $container = $this->createContainerFromFile('validation_auto_mapping'); $parameter = [ 'App\\' => ['services' => ['foo', 'bar']], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php index 82e6bf8bb150..7390a124c3c0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php @@ -92,10 +92,6 @@ public function testSearchWithThrow() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $tester = new CommandCompletionTester($this->application->get('debug:router')); $this->assertSame($expectedSuggestions, $tester->complete($input)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php index f6098ea6e8ec..8c43917df6f5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php @@ -23,7 +23,6 @@ use Symfony\Component\HttpFoundation\Cookie as HttpFoundationCookie; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Test\Constraint\ResponseFormatSame; class WebTestCaseTest extends TestCase { @@ -78,10 +77,6 @@ public function testAssertResponseRedirectsWithLocationAndStatusCode() public function testAssertResponseFormat() { - if (!class_exists(ResponseFormatSame::class)) { - $this->markTestSkipped('Too old version of HttpFoundation.'); - } - $this->getResponseTester(new Response('', 200, ['Content-Type' => 'application/vnd.myformat']))->assertResponseFormatSame('custom'); $this->getResponseTester(new Response('', 200, ['Content-Type' => 'application/ld+json']))->assertResponseFormatSame('jsonld'); $this->getResponseTester(new Response())->assertResponseFormatSame(null); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index f695c428712f..007cb61130e5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\Definition\BaseNode; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Resource\FileResource; @@ -135,10 +134,6 @@ public function testThrowingExtensionsGetMergedBag() public function testReuseEnvPlaceholderGeneratedByPreviousExtension() { - if (!property_exists(BaseNode::class, 'placeholderUniquePrefixes')) { - $this->markTestSkipped('This test requires symfony/config ^4.4.11|^5.0.11|^5.1.3'); - } - $container = new ContainerBuilder(); $container->registerExtension(new FooExtension()); $container->registerExtension(new TestCccExtension()); diff --git a/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php index 806bc2e18103..374c3ca9493d 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php @@ -29,8 +29,6 @@ public function testAddHtml5() /** @dataProvider validHtml5Provider */ public function testHtml5ParserParseContentStartingWithValidHeading(string $content) { - $this->skipTestIfHTML5LibraryNotAvailable(); - $crawler = $this->createCrawler(); $crawler->addHtmlContent($content); self::assertEquals( @@ -43,8 +41,6 @@ public function testHtml5ParserParseContentStartingWithValidHeading(string $cont /** @dataProvider invalidHtml5Provider */ public function testHtml5ParserWithInvalidHeadedContent(string $content) { - $this->skipTestIfHTML5LibraryNotAvailable(); - $crawler = $this->createCrawler(); $crawler->addHtmlContent($content); self::assertEmpty($crawler->filterXPath('//h1')->text(), '->addHtmlContent failed as expected'); @@ -70,11 +66,4 @@ public function invalidHtml5Provider(): iterable yield 'Text' => ['hello world'.$html]; yield 'Text between comments' => [' test '.$html]; } - - private function skipTestIfHTML5LibraryNotAvailable(): void - { - if (!class_exists(\Masterminds\HTML5::class)) { - self::markTestSkipped('HTML5 library is not available'); - } - } } diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index 4d9df07a9a1e..f63e4f3268bc 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -249,10 +249,6 @@ public function testInvokableEventListener() public function testTaggedInvokableEventListener() { - if (!class_exists(AttributeAutoconfigurationPass::class)) { - self::markTestSkipped('This test requires Symfony DependencyInjection >= 5.3'); - } - $container = new ContainerBuilder(); $container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute): void { $definition->addTag('kernel.event_listener', get_object_vars($attribute)); @@ -280,10 +276,6 @@ public function testTaggedInvokableEventListener() public function testTaggedMultiEventListener() { - if (!class_exists(AttributeAutoconfigurationPass::class)) { - self::markTestSkipped('This test requires Symfony DependencyInjection >= 5.3'); - } - $container = new ContainerBuilder(); $container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute, \ReflectionClass|\ReflectionMethod $reflector): void { diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index be54d2350d8a..ad52a4fd25c2 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -189,10 +189,6 @@ class:%s */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $formRegistry = new FormRegistry([], new ResolvedFormTypeFactory()); $command = new DebugCommand($formRegistry); $application = new Application(); diff --git a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php index b818dcd8c487..b9add5877e1e 100644 --- a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php +++ b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php @@ -26,10 +26,6 @@ class FormErrorIteratorTest extends TestCase */ public function testFindByCodes($code, $violationsCount) { - if (!class_exists(ConstraintViolation::class)) { - $this->markTestSkipped('Validator component required.'); - } - $formBuilder = new FormBuilder( 'form', null, diff --git a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php index 7d96f730d7ea..05da3a0a3e57 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php @@ -117,10 +117,6 @@ public function testGenerateAbsoluteUrlWithScriptFileName() */ public function testGenerateRelativePath($expected, $path, $pathinfo) { - if (!method_exists(Request::class, 'getRelativeUriForPath')) { - $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.'); - } - $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); $urlHelper = new UrlHelper($stack); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index dab60d402bb2..b58dd7de7825 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -192,10 +192,6 @@ public function provideLevelsAssignedToLoggers(): array */ public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecationLogger, $levels, $expectedLoggerLevels, $expectedDeprecationLoggerLevels) { - if (!class_exists(ErrorHandler::class)) { - $this->markTestSkipped('ErrorHandler component is required to run this test.'); - } - $handler = $this->createMock(ErrorHandler::class); $expectedCalls = []; diff --git a/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php b/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php index f62029b594a1..1ff3503cac2d 100644 --- a/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php @@ -41,10 +41,6 @@ class CheckLdapCredentialsListenerTest extends TestCase protected function setUp(): void { - if (!interface_exists(AuthenticatorInterface::class)) { - $this->markTestSkipped('This test requires symfony/security-http:^5.1'); - } - $this->ldap = $this->createMock(LdapInterface::class); } @@ -61,10 +57,6 @@ public function testShouldNotCheckPassport($authenticator, $passport) public function provideShouldNotCheckPassport() { - if (!interface_exists(AuthenticatorInterface::class)) { - $this->markTestSkipped('This test requires symfony/security-http:^5.1'); - } - // no LdapBadge yield [new TestAuthenticator(), new Passport(new UserBadge('test'), new PasswordCredentials('s3cret'))]; @@ -110,10 +102,6 @@ public function testWrongPassport($passport) public function provideWrongPassportData() { - if (!interface_exists(AuthenticatorInterface::class)) { - $this->markTestSkipped('This test requires symfony/security-http:^5.1'); - } - // no password credentials yield [new SelfValidatingPassport(new UserBadge('test'), [new LdapBadge('app.ldap')])]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php index f2740d6e3545..ef6d2a51a26c 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php @@ -224,10 +224,6 @@ public function testEnvelopeSenderAndRecipients() public function testTagAndMetadataHeaders() { - if (!class_exists(TagHeader::class)) { - $this->markTestSkipped('This test requires symfony/mailer 5.1 or higher.'); - } - $email = new Email(); $email->getHeaders()->add(new TagHeader('category-one')); $email->getHeaders()->add(new MetadataHeader('Color', 'blue')); diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index af2d0e3e9fa7..eadc2f21c8df 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -174,10 +174,6 @@ public function testExceptionOnUnknownBusArgument() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $command = new DebugCommand(['command_bus' => [], 'query_bus' => []]); $application = new Application(); $application->add($command); diff --git a/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php b/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php index e619220904d1..c038e757571e 100644 --- a/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php +++ b/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php @@ -292,10 +292,6 @@ public function testThrowsExceptionOnNoConfiguredHashers() */ public function testCompletionSuggestions(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $command = new UserPasswordHashCommand($this->createMock(PasswordHasherFactoryInterface::class), ['App\Entity\User']); $tester = new CommandCompletionTester($command); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php index 397ac4b1ad0f..fc8b6890f844 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\PropertyInfo\Tests\Extractor; -use phpDocumentor\Reflection\Types\Collection; use PHPUnit\Framework\TestCase; use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy; @@ -137,10 +136,6 @@ public function typesProvider() */ public function testExtractCollection($property, array $type = null, $shortDescription, $longDescription) { - if (!class_exists(Collection::class)) { - $this->markTestSkipped('Collections are not implemented in current phpdocumentor/type-resolver version'); - } - $this->testExtract($property, $type, $shortDescription, $longDescription); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php index 02b19b74a6c9..66d8c06b3e6f 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php @@ -16,7 +16,6 @@ use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor; use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy; use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy; -use Symfony\Component\Serializer\Annotation\Ignore; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -46,10 +45,6 @@ public function testGetProperties() public function testGetPropertiesWithIgnoredProperties() { - if (!class_exists(Ignore::class)) { - $this->markTestSkipped('Ignore annotation is not implemented in current symfony/serializer version'); - } - $this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['a']])); } diff --git a/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php index c002fc7532b1..d60c2d2f5e7a 100644 --- a/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php @@ -602,10 +602,6 @@ public function testPullMessagesMultipleDomains() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $application = new Application(); $application->add($this->createCommand($this->createMock(ProviderInterface::class), ['en', 'fr', 'it'], ['messages', 'validators'], 'en', ['loco', 'crowdin', 'lokalise'])); diff --git a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php index 9fcd0d77b183..920fd361d353 100644 --- a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php @@ -328,10 +328,6 @@ public function testPushWithProviderDomains() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $application = new Application(); $application->add($this->createCommand($this->createMock(ProviderInterface::class), ['en', 'fr', 'it'], ['messages', 'validators'], ['loco', 'crowdin', 'lokalise'])); diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php index 39e74fac96d9..8992569b01d8 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php @@ -12,19 +12,11 @@ namespace Symfony\Component\Translation\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\Translation\DataCollector\TranslationDataCollector; use Symfony\Component\Translation\DataCollectorTranslator; class TranslationDataCollectorTest extends TestCase { - protected function setUp(): void - { - if (!class_exists(DataCollector::class)) { - $this->markTestSkipped('The "DataCollector" is not available'); - } - } - public function testCollectEmptyMessages() { $translator = $this->getTranslator(); diff --git a/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php b/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php index 48814de9c72f..c304915ad73b 100644 --- a/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php +++ b/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php @@ -108,10 +108,6 @@ public function testUlidsAreDifferentWhenGeneratingSeveralNow() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $application = new Application(); $application->add(new GenerateUlidCommand()); $tester = new CommandCompletionTester($application->get('ulid:generate')); diff --git a/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php b/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php index 65b9f87f7063..d95d2c4e0dba 100644 --- a/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php +++ b/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php @@ -237,10 +237,6 @@ public function testNamespacePredefinedKeyword() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $application = new Application(); $application->add(new GenerateUuidCommand()); $tester = new CommandCompletionTester($application->get('uuid:generate')); diff --git a/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php b/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php index fe1a9b05d3da..664a520dc167 100644 --- a/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php @@ -23,10 +23,6 @@ class ServerDumpCommandTest extends TestCase */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $tester = new CommandCompletionTester($this->createCommand()); $this->assertSame($expectedSuggestions, $tester->complete($input)); diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index 90e20455ff0e..d160f7b52f3c 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -92,10 +92,6 @@ public function testLintIncorrectFileWithGithubFormat() public function testLintAutodetectsGithubActionEnvironment() { - if (!class_exists(GithubActionReporter::class)) { - $this->markTestSkipped('The "github" format is only available since "symfony/console" >= 5.3.'); - } - $prev = getenv('GITHUB_ACTIONS'); putenv('GITHUB_ACTIONS'); @@ -170,10 +166,6 @@ public function testLintFileNotReadable() */ public function testComplete(array $input, array $expectedSuggestions) { - if (!class_exists(CommandCompletionTester::class)) { - $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); - } - $tester = new CommandCompletionTester($this->createCommand()); $this->assertSame($expectedSuggestions, $tester->complete($input)); From 61fc50c53007118c0b41a6abb23c36c7778c9740 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 15 Apr 2022 16:43:40 +0200 Subject: [PATCH 09/60] Fix documentation of allow* function calls --- src/Symfony/Component/HtmlSanitizer/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HtmlSanitizer/README.md b/src/Symfony/Component/HtmlSanitizer/README.md index 12210c8a87db..70cdc476e258 100644 --- a/src/Symfony/Component/HtmlSanitizer/README.md +++ b/src/Symfony/Component/HtmlSanitizer/README.md @@ -63,19 +63,19 @@ $config = (new HtmlSanitizerConfig()) ->forceHttpsUrls() // Configure which schemes are allowed in links (others will be dropped) - ->allowedLinkSchemes(['https', 'http', 'mailto']) + ->allowLinkSchemes(['https', 'http', 'mailto']) // Configure which hosts are allowed in links (by default all are allowed) - ->allowedLinkHosts(['symfony.com', 'example.com']) + ->allowLinkHosts(['symfony.com', 'example.com']) // Allow relative URL in links (by default they are dropped) ->allowRelativeLinks() // Configure which schemes are allowed in img/audio/video/iframe (others will be dropped) - ->allowedMediaSchemes(['https', 'http']) + ->allowMediaSchemes(['https', 'http']) // Configure which hosts are allowed in img/audio/video/iframe (by default all are allowed) - ->allowedMediaHosts(['symfony.com', 'example.com']) + ->allowMediaHosts(['symfony.com', 'example.com']) // Allow relative URL in img/audio/video/iframe (by default they are dropped) ->allowRelativeMedias() From 070f2cfc039a9d7c7bf344ffc3875c8da3dcbc1d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 15 Apr 2022 17:00:35 +0200 Subject: [PATCH 10/60] [HtmlSanitizer] Add HtmlSanitizerConfig::withMaxInputLength() --- .../DependencyInjection/Configuration.php | 4 ++++ .../DependencyInjection/FrameworkExtension.php | 4 ++++ .../Resources/config/schema/symfony-1.0.xsd | 1 + .../Component/HtmlSanitizer/HtmlSanitizer.php | 8 +++----- .../HtmlSanitizer/HtmlSanitizerConfig.php | 15 +++++++++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 3d4408153b96..5794020b4447 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -2243,6 +2243,10 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable ->info('Unregisters custom attribute sanitizers.') ->scalarPrototype()->end() ->end() + ->integerNode('max_input_length') + ->info('The maximum length allowed for the sanitized input.') + ->defaultValue(0) + ->end() ->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index af64c9bc807d..d21de7da9d1f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2734,6 +2734,10 @@ private function registerHtmlSanitizerConfiguration(array $config, ContainerBuil $def->addMethodCall('withoutAttributeSanitizer', [new Reference($serviceName)], true); } + if ($sanitizerConfig['max_input_length']) { + $def->addMethodCall('withMaxInputLength', [$sanitizerConfig['max_input_length']], true); + } + // Create the sanitizer and link its config $sanitizerId = 'html_sanitizer.sanitizer.'.$sanitizerName; $container->register($sanitizerId, HtmlSanitizer::class)->addArgument(new Reference($configId)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 3ffa5b571503..c2bf87f9daf4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -850,6 +850,7 @@ + diff --git a/src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php b/src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php index 78687d6cc2d4..2f4947256602 100644 --- a/src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php +++ b/src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php @@ -25,7 +25,6 @@ final class HtmlSanitizer implements HtmlSanitizerInterface { private HtmlSanitizerConfig $config; - private int $maxInputLength; private ParserInterface $parser; /** @@ -33,10 +32,9 @@ final class HtmlSanitizer implements HtmlSanitizerInterface */ private array $domVisitors = []; - public function __construct(HtmlSanitizerConfig $config, int $maxInputLength = 20000, ParserInterface $parser = null) + public function __construct(HtmlSanitizerConfig $config, ParserInterface $parser = null) { $this->config = $config; - $this->maxInputLength = $maxInputLength; $this->parser = $parser ?? new MastermindsParser(); } @@ -64,8 +62,8 @@ private function sanitizeWithContext(string $context, string $input): string $this->domVisitors[$context] ??= $this->createDomVisitorForContext($context); // Prevent DOS attack induced by extremely long HTML strings - if (\strlen($input) > $this->maxInputLength) { - $input = substr($input, 0, $this->maxInputLength); + if (\strlen($input) > $this->config->getMaxInputLength()) { + $input = substr($input, 0, $this->config->getMaxInputLength()); } // Only operate on valid UTF-8 strings. This is necessary to prevent cross diff --git a/src/Symfony/Component/HtmlSanitizer/HtmlSanitizerConfig.php b/src/Symfony/Component/HtmlSanitizer/HtmlSanitizerConfig.php index 81a2812a5c86..34576ca9d95c 100644 --- a/src/Symfony/Component/HtmlSanitizer/HtmlSanitizerConfig.php +++ b/src/Symfony/Component/HtmlSanitizer/HtmlSanitizerConfig.php @@ -92,6 +92,8 @@ class HtmlSanitizerConfig */ private array $attributeSanitizers; + private int $maxInputLength = 20_000; + public function __construct() { $this->attributeSanitizers = [ @@ -405,6 +407,19 @@ public function withoutAttributeSanitizer(AttributeSanitizerInterface $sanitizer return $clone; } + public function withMaxInputLength(int $maxInputLength): static + { + $clone = clone $this; + $clone->maxInputLength = $maxInputLength; + + return $clone; + } + + public function getMaxInputLength(): int + { + return $this->maxInputLength; + } + /** * @return array> */ From 3ed91c4cce1754d5ae1700a6bbd5ab32d5bcafb9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Mar 2022 19:26:32 +0200 Subject: [PATCH 11/60] bug #45452 [Security] Fix UserNotFoundException is not thrown (damienfa) This PR was merged into the 5.4 branch. Discussion ---------- [Security] Fix UserNotFoundException is not thrown | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #45070 | License | MIT | Doc PR | N/A Commits ------- 7e0ed85d9a Fix issue 45070 : UserNotFoundException is not thrown --- .../Http/Authenticator/Passport/Badge/UserBadge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php index 8357158cc48b..7d43d01b3a30 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php @@ -13,6 +13,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\AuthenticationServiceException; +use Symfony\Component\Security\Core\Exception\UserNotFoundException; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Http\EventListener\UserProviderListener; @@ -65,6 +66,15 @@ public function getUser(): UserInterface } $this->user = ($this->userLoader)($this->userIdentifier); + + // No user has been found via the $this->userLoader callback + if (null === $this->user) { + $exception = new UserNotFoundException(); + $exception->setUserIdentifier($this->userIdentifier); + + throw $exception; + } + if (!$this->user instanceof UserInterface) { throw new AuthenticationServiceException(sprintf('The user provider must return a UserInterface object, "%s" given.', get_debug_type($this->user))); } From 7ba23e8ffed0ad2505ca45d12cd06bc920aede8a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 15 Apr 2022 17:14:47 +0200 Subject: [PATCH 12/60] cs fix --- .../Passport/Badge/UserBadge.php | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php index 7d43d01b3a30..5e8dbdc700e0 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php @@ -60,27 +60,29 @@ public function getUserIdentifier(): string */ public function getUser(): UserInterface { - if (null === $this->user) { - if (null === $this->userLoader) { - throw new \LogicException(sprintf('No user loader is configured, did you forget to register the "%s" listener?', UserProviderListener::class)); - } + if (null !== $this->user) { + return $this->user; + } + + if (null === $this->userLoader) { + throw new \LogicException(sprintf('No user loader is configured, did you forget to register the "%s" listener?', UserProviderListener::class)); + } - $this->user = ($this->userLoader)($this->userIdentifier); + $user = ($this->userLoader)($this->userIdentifier); - // No user has been found via the $this->userLoader callback - if (null === $this->user) { - $exception = new UserNotFoundException(); - $exception->setUserIdentifier($this->userIdentifier); + // No user has been found via the $this->userLoader callback + if (null === $user) { + $exception = new UserNotFoundException(); + $exception->setUserIdentifier($this->userIdentifier); - throw $exception; - } + throw $exception; + } - if (!$this->user instanceof UserInterface) { - throw new AuthenticationServiceException(sprintf('The user provider must return a UserInterface object, "%s" given.', get_debug_type($this->user))); - } + if (!$user instanceof UserInterface) { + throw new AuthenticationServiceException(sprintf('The user provider must return a UserInterface object, "%s" given.', get_debug_type($user))); } - return $this->user; + return $this->user = $user; } public function getUserLoader(): ?callable From 4a75e98252d72af4813d424fe1b46d0f5b1595eb Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Fri, 15 Apr 2022 17:19:40 +0200 Subject: [PATCH 13/60] [Security] Add test case for user not found --- .../Passport/Badge/UserBadgeTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Symfony/Component/Security/Http/Tests/Authenticator/Passport/Badge/UserBadgeTest.php diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/Passport/Badge/UserBadgeTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/Passport/Badge/UserBadgeTest.php new file mode 100644 index 000000000000..d8e4c4cbdd29 --- /dev/null +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/Passport/Badge/UserBadgeTest.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Http\Tests\Authenticator\Passport\Badge; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Security\Core\Exception\UserNotFoundException; +use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; + +class UserBadgeTest extends TestCase +{ + public function testUserNotFound() + { + $badge = new UserBadge('dummy', function () { return null; }); + $this->expectException(UserNotFoundException::class); + $badge->getUser(); + } +} From 68f5b3c7363ca08354a8733d7c132b03f661e7cf Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 15 Apr 2022 17:20:02 +0200 Subject: [PATCH 14/60] =?UTF-8?q?=C2=B5fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Security/Http/Authenticator/Passport/Badge/UserBadge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php index 5aeeb2fc628f..abbf267d531c 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge/UserBadge.php @@ -61,7 +61,7 @@ public function getUserIdentifier(): string */ public function getUser(): UserInterface { - if (null !== $this->user) { + if (isset($this->user)) { return $this->user; } From 3677d4991a164bd655bd98625e65be4f27583e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=99=9A=20PH=E2=91=A6=20de=20Soria=E2=84=A2=E2=99=9B?= Date: Sat, 16 Apr 2022 04:10:11 +0930 Subject: [PATCH 15/60] [Mailer] Missing import in first example In README, Getting Started section, the first example had `use Symfony\Component\Mime\Email; ` missing. | Q | A | ------------- | --- | Branch? | 4.4 for features / 4.4, 5.4 or 6.0 for bug fixes | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | symfony/symfony-docs#... --- src/Symfony/Component/Mailer/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Mailer/README.md b/src/Symfony/Component/Mailer/README.md index 05c56fddf325..93a958582264 100644 --- a/src/Symfony/Component/Mailer/README.md +++ b/src/Symfony/Component/Mailer/README.md @@ -13,6 +13,7 @@ $ composer require symfony/mailer ```php use Symfony\Component\Mailer\Transport; use Symfony\Component\Mailer\Mailer; +use Symfony\Component\Mime\Email; $transport = Transport::fromDsn('smtp://localhost'); $mailer = new Mailer($transport); From 181da1165e79746ec100af56513bea26a8f6d2d2 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Sun, 17 Apr 2022 00:36:28 +0200 Subject: [PATCH 16/60] Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- .../Resources/views/Profiler/base_js.html.twig | 6 +++--- src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index 859b7b2f28ab..53de710fdc2f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -331,13 +331,13 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') { /* prevent logging AJAX calls to static and inline files, like templates */ var path = url; - if (url.substr(0, 1) === '/') { + if (url.slice(0, 1) === '/') { if (0 === url.indexOf('{{ request.basePath|e('js') }}')) { - path = url.substr({{ request.basePath|length }}); + path = url.slice({{ request.basePath|length }}); } } else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) { - path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }}); + path = url.slice({{ (request.schemeAndHttpHost ~ request.basePath)|length }}); } if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 88e5ba928403..4db0f08efbc1 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -371,7 +371,7 @@ function xpathHasClass(className) { if (/\bsf-dump-toggle\b/.test(a.className)) { e.preventDefault(); if (!toggle(a, isCtrlKey(e))) { - var r = doc.getElementById(a.getAttribute('href').substr(1)), + var r = doc.getElementById(a.getAttribute('href').slice(1)), s = r.previousSibling, f = r.parentNode, t = a.parentNode; @@ -438,7 +438,7 @@ function xpathHasClass(className) { toggle(a); } } else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) { - a = a.substr(1); + a = a.slice(1); elt.className += ' '+a; if (/[\[{]$/.test(elt.previousSibling.nodeValue)) { From a53b450d208e2435f697d806b4ef12cc411d91be Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 13 Apr 2022 16:22:34 +0200 Subject: [PATCH 17/60] do not use mocks in tests when not necessary --- .../Component/Form/Tests/AbstractFormTest.php | 77 --- .../Form/Tests/AbstractRequestHandlerTest.php | 5 +- .../Component/Form/Tests/ButtonTest.php | 18 +- .../Factory/CachingFactoryDecoratorTest.php | 429 +++++---------- .../Factory/DefaultChoiceListFactoryTest.php | 6 +- .../Factory/PropertyAccessDecoratorTest.php | 227 ++------ .../Tests/ChoiceList/LazyChoiceListTest.php | 194 +++---- .../Component/Form/Tests/CompoundFormTest.php | 338 +++++------- .../BaseDateTimeTransformerTest.php | 8 +- .../DataTransformerChainTest.php | 34 +- .../DateTimeToArrayTransformerTest.php | 9 +- ...imeToHtml5LocalDateTimeTransformerTest.php | 9 +- ...teTimeToLocalizedStringTransformerTest.php | 9 +- .../DateTimeToRfc3339TransformerTest.php | 9 +- .../DateTimeToStringTransformerTest.php | 9 +- .../DateTimeToTimestampTransformerTest.php | 9 +- ...ercentToLocalizedStringTransformerTest.php | 23 +- .../Extension/Core/Type/FileTypeTest.php | 33 +- .../CsrfValidationListenerTest.php | 17 +- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 19 +- .../DataCollectorExtensionTest.php | 12 +- .../DataCollector/FormDataCollectorTest.php | 505 ++++++------------ .../DataCollector/FormDataExtractorTest.php | 57 +- .../Type/DataCollectorTypeExtensionTest.php | 40 +- .../DependencyInjectionExtensionTest.php | 3 +- .../Constraints/FormValidatorTest.php | 2 +- .../Form/Tests/Fixtures/ArrayChoiceLoader.php | 15 + .../Tests/Fixtures/ConfigurableFormType.php | 28 + .../Component/Form/Tests/Fixtures/Map.php | 38 ++ .../Tests/Fixtures/NullFormTypeGuesser.php | 39 ++ .../Component/Form/Tests/FormBuilderTest.php | 85 +-- .../Component/Form/Tests/FormConfigTest.php | 10 +- .../Form/Tests/FormErrorIteratorTest.php | 6 +- .../Form/Tests/FormFactoryBuilderTest.php | 6 +- .../Component/Form/Tests/FormFactoryTest.php | 467 ++++------------ .../Component/Form/Tests/FormRegistryTest.php | 102 +--- .../Component/Form/Tests/FormRendererTest.php | 21 +- .../Form/Tests/ResolvedFormTypeTest.php | 376 +++++-------- .../Component/Form/Tests/SimpleFormTest.php | 203 ++++--- 39 files changed, 1284 insertions(+), 2213 deletions(-) delete mode 100644 src/Symfony/Component/Form/Tests/AbstractFormTest.php create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/ArrayChoiceLoader.php create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/ConfigurableFormType.php create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/Map.php create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/NullFormTypeGuesser.php diff --git a/src/Symfony/Component/Form/Tests/AbstractFormTest.php b/src/Symfony/Component/Form/Tests/AbstractFormTest.php deleted file mode 100644 index 193bb31b15ed..000000000000 --- a/src/Symfony/Component/Form/Tests/AbstractFormTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Form\DataMapperInterface; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormFactoryInterface; -use Symfony\Component\Form\FormInterface; - -abstract class AbstractFormTest extends TestCase -{ - /** - * @var EventDispatcherInterface - */ - protected $dispatcher; - - /** - * @var MockObject&FormFactoryInterface - */ - protected $factory; - - /** - * @var FormInterface - */ - protected $form; - - protected function setUp(): void - { - $this->dispatcher = new EventDispatcher(); - $this->factory = $this->createMock(FormFactoryInterface::class); - $this->form = $this->createForm(); - } - - protected function tearDown(): void - { - $this->dispatcher = null; - $this->factory = null; - $this->form = null; - } - - abstract protected function createForm(): FormInterface; - - protected function getBuilder(?string $name = 'name', EventDispatcherInterface $dispatcher = null, string $dataClass = null, array $options = []): FormBuilder - { - return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory, $options); - } - - /** - * @return MockObject&DataMapperInterface - */ - protected function getDataMapper(): DataMapperInterface - { - return $this->createMock(DataMapperInterface::class); - } - - /** - * @return MockObject&DataTransformerInterface - */ - protected function getDataTransformer(): DataTransformerInterface - { - return $this->createMock(DataTransformerInterface::class); - } -} diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index 857b2bbde469..a1fd4285bda5 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -18,9 +18,10 @@ use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormFactory; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\Forms; use Symfony\Component\Form\RequestHandlerInterface; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\Util\ServerParams; /** @@ -417,7 +418,7 @@ protected function createForm($name, $method = null, $compound = false) protected function createBuilder($name, $compound = false, array $options = []) { - $builder = new FormBuilder($name, null, new EventDispatcher(), $this->createMock(FormFactoryInterface::class), $options); + $builder = new FormBuilder($name, null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), $options); $builder->setCompound($compound); if ($compound) { diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php index e665eca5f804..0113acab2493 100644 --- a/src/Symfony/Component/Form/Tests/ButtonTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonTest.php @@ -12,27 +12,19 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\ButtonBuilder; use Symfony\Component\Form\Exception\AlreadySubmittedException; use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormRegistry; +use Symfony\Component\Form\ResolvedFormTypeFactory; /** * @author Bernhard Schussek */ class ButtonTest extends TestCase { - private $dispatcher; - - private $factory; - - protected function setUp(): void - { - $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->factory = $this->createMock(FormFactoryInterface::class); - } - public function testSetParentOnSubmittedButton() { $this->expectException(AlreadySubmittedException::class); @@ -83,6 +75,6 @@ private function getButtonBuilder($name) private function getFormBuilder() { - return new FormBuilder('form', null, $this->dispatcher, $this->factory); + return new FormBuilder('form', null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory()))); } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index 38c4041bd74d..de2a70efa869 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -11,25 +11,18 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; +use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; /** * @author Bernhard Schussek */ class CachingFactoryDecoratorTest extends TestCase { - /** - * @var MockObject&ChoiceListFactoryInterface - */ - private $decoratedFactory; - /** * @var CachingFactoryDecorator */ @@ -37,21 +30,17 @@ class CachingFactoryDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->createMock(ChoiceListFactoryInterface::class); - $this->factory = new CachingFactoryDecorator($this->decoratedFactory); + $this->factory = new CachingFactoryDecorator(new DefaultChoiceListFactory()); } public function testCreateFromChoicesEmpty() { - $list = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with([]) - ->willReturn($list); + $list1 = $this->factory->createListFromChoices([]); + $list2 = $this->factory->createListFromChoices([]); - $this->assertSame($list, $this->factory->createListFromChoices([])); - $this->assertSame($list, $this->factory->createListFromChoices([])); + $this->assertSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList([]), $list1); + $this->assertEquals(new ArrayChoiceList([]), $list2); } public function testCreateFromChoicesComparesTraversableChoicesAsArray() @@ -59,34 +48,25 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray() // The top-most traversable is converted to an array $choices1 = new \ArrayIterator(['A' => 'a']); $choices2 = ['A' => 'a']; - $list = new ArrayChoiceList([]); - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices2) - ->willReturn($list); + $list1 = $this->factory->createListFromChoices($choices1); + $list2 = $this->factory->createListFromChoices($choices2); - $this->assertSame($list, $this->factory->createListFromChoices($choices1)); - $this->assertSame($list, $this->factory->createListFromChoices($choices2)); + $this->assertSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list1); + $this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2); } public function testCreateFromChoicesGroupedChoices() { $choices1 = ['key' => ['A' => 'a']]; $choices2 = ['A' => 'a']; - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromChoices') - ->withConsecutive( - [$choices1], - [$choices2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); - $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); + $list1 = $this->factory->createListFromChoices($choices1); + $list2 = $this->factory->createListFromChoices($choices2); + + $this->assertNotSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList(['key' => ['A' => 'a']]), $list1); + $this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2); } /** @@ -94,17 +74,12 @@ public function testCreateFromChoicesGroupedChoices() */ public function testCreateFromChoicesSameChoices($choice1, $choice2) { - $choices1 = [$choice1]; - $choices2 = [$choice2]; - $list = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices1) - ->willReturn($list); + $list1 = $this->factory->createListFromChoices([$choice1]); + $list2 = $this->factory->createListFromChoices([$choice2]); - $this->assertSame($list, $this->factory->createListFromChoices($choices1)); - $this->assertSame($list, $this->factory->createListFromChoices($choices2)); + $this->assertSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList([$choice1]), $list1); + $this->assertEquals(new ArrayChoiceList([$choice2]), $list2); } /** @@ -112,369 +87,245 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2) */ public function testCreateFromChoicesDifferentChoices($choice1, $choice2) { - $choices1 = [$choice1]; - $choices2 = [$choice2]; - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromChoices') - ->withConsecutive( - [$choices1], - [$choices2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); - $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); + $list1 = $this->factory->createListFromChoices([$choice1]); + $list2 = $this->factory->createListFromChoices([$choice2]); + + $this->assertNotSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList([$choice1]), $list1); + $this->assertEquals(new ArrayChoiceList([$choice2]), $list2); } public function testCreateFromChoicesSameValueClosure() { $choices = [1]; - $list = new ArrayChoiceList([]); $closure = function () {}; - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $closure) - ->willReturn($list); + $list1 = $this->factory->createListFromChoices($choices, $closure); + $list2 = $this->factory->createListFromChoices($choices, $closure); - $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); - $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); + $this->assertSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList($choices, $closure), $list1); + $this->assertEquals(new ArrayChoiceList($choices, $closure), $list2); } public function testCreateFromChoicesDifferentValueClosure() { $choices = [1]; - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); $closure1 = function () {}; $closure2 = function () {}; + $list1 = $this->factory->createListFromChoices($choices, $closure1); + $list2 = $this->factory->createListFromChoices($choices, $closure2); - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromChoices') - ->withConsecutive( - [$choices, $closure1], - [$choices, $closure2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1)); - $this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2)); + $this->assertNotSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList($choices, $closure1), $list1); + $this->assertEquals(new ArrayChoiceList($choices, $closure2), $list2); } public function testCreateFromLoaderSameLoader() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader) - ->willReturn($list); + $loader = new ArrayChoiceLoader(); - $this->assertSame($list, $this->factory->createListFromLoader($loader)); - $this->assertSame($list, $this->factory->createListFromLoader($loader)); + $this->assertSame($this->factory->createListFromLoader($loader), $this->factory->createListFromLoader($loader)); } public function testCreateFromLoaderDifferentLoader() { - $loader1 = $this->createMock(ChoiceLoaderInterface::class); - $loader2 = $this->createMock(ChoiceLoaderInterface::class); - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromLoader') - ->withConsecutive( - [$loader1], - [$loader2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $this->factory->createListFromLoader($loader1)); - $this->assertSame($list2, $this->factory->createListFromLoader($loader2)); + $this->assertNotSame($this->factory->createListFromLoader(new ArrayChoiceLoader()), $this->factory->createListFromLoader(new ArrayChoiceLoader())); } public function testCreateFromLoaderSameValueClosure() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list = new ArrayChoiceList([]); + $loader = new ArrayChoiceLoader(); $closure = function () {}; - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $closure) - ->willReturn($list); - - $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); - $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); + $this->assertSame($this->factory->createListFromLoader($loader, $closure), $this->factory->createListFromLoader($loader, $closure)); } public function testCreateFromLoaderDifferentValueClosure() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); + $loader = new ArrayChoiceLoader(); $closure1 = function () {}; $closure2 = function () {}; - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromLoader') - ->withConsecutive( - [$loader, $closure1], - [$loader, $closure2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1)); - $this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2)); + $this->assertNotSame($this->factory->createListFromLoader($loader, $closure1), $this->factory->createListFromLoader($loader, $closure2)); } public function testCreateViewSamePreferredChoices() { $preferred = ['a']; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $preferred) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, $preferred); + $view2 = $this->factory->createView($list, $preferred); - $this->assertSame($view, $this->factory->createView($list, $preferred)); - $this->assertSame($view, $this->factory->createView($list, $preferred)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentPreferredChoices() { $preferred1 = ['a']; $preferred2 = ['b']; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, $preferred1], - [$list, $preferred2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, $preferred1)); - $this->assertSame($view2, $this->factory->createView($list, $preferred2)); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, $preferred1); + $view2 = $this->factory->createView($list, $preferred2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSamePreferredChoicesClosure() { $preferred = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $preferred) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, $preferred); + $view2 = $this->factory->createView($list, $preferred); - $this->assertSame($view, $this->factory->createView($list, $preferred)); - $this->assertSame($view, $this->factory->createView($list, $preferred)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentPreferredChoicesClosure() { $preferred1 = function () {}; $preferred2 = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, $preferred1], - [$list, $preferred2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, $preferred1)); - $this->assertSame($view2, $this->factory->createView($list, $preferred2)); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, $preferred1); + $view2 = $this->factory->createView($list, $preferred2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSameLabelClosure() { $labels = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, $labels) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, $labels); + $view2 = $this->factory->createView($list, null, $labels); - $this->assertSame($view, $this->factory->createView($list, null, $labels)); - $this->assertSame($view, $this->factory->createView($list, null, $labels)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentLabelClosure() { $labels1 = function () {}; $labels2 = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, null, $labels1], - [$list, null, $labels2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, null, $labels1)); - $this->assertSame($view2, $this->factory->createView($list, null, $labels2)); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, $labels1); + $view2 = $this->factory->createView($list, null, $labels2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSameIndexClosure() { $index = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, $index) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, $index); + $view2 = $this->factory->createView($list, null, null, $index); - $this->assertSame($view, $this->factory->createView($list, null, null, $index)); - $this->assertSame($view, $this->factory->createView($list, null, null, $index)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentIndexClosure() { $index1 = function () {}; $index2 = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, null, null, $index1], - [$list, null, null, $index2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, null, null, $index1)); - $this->assertSame($view2, $this->factory->createView($list, null, null, $index2)); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, $index1); + $view2 = $this->factory->createView($list, null, null, $index2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSameGroupByClosure() { $groupBy = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, $groupBy) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, $groupBy); + $view2 = $this->factory->createView($list, null, null, null, $groupBy); - $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); - $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentGroupByClosure() { $groupBy1 = function () {}; $groupBy2 = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, null, null, null, $groupBy1], - [$list, null, null, null, $groupBy2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1)); - $this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2)); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, $groupBy1); + $view2 = $this->factory->createView($list, null, null, null, $groupBy2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSameAttributes() { $attr = ['class' => 'foobar']; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); + $list = new ArrayChoiceList([]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $attr) - ->willReturn($view); + $view1 = $this->factory->createView($list, null, null, null, null, $attr); + $view2 = $this->factory->createView($list, null, null, null, null, $attr); - $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); - $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentAttributes() { $attr1 = ['class' => 'foobar1']; $attr2 = ['class' => 'foobar2']; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, null, null, null, null, $attr1], - [$list, null, null, null, null, $attr2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); - $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); + $list = new ArrayChoiceList([]); + + $view1 = $this->factory->createView($list, null, null, null, null, $attr1); + $view2 = $this->factory->createView($list, null, null, null, null, $attr2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewSameAttributesClosure() { $attr = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $attr) - ->willReturn($view); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, null, $attr); + $view2 = $this->factory->createView($list, null, null, null, null, $attr); - $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); - $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentAttributesClosure() { $attr1 = function () {}; $attr2 = function () {}; - $list = $this->createMock(ChoiceListInterface::class); - $view1 = new ChoiceListView(); - $view2 = new ChoiceListView(); - - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createView') - ->withConsecutive( - [$list, null, null, null, null, $attr1], - [$list, null, null, null, null, $attr2] - ) - ->willReturnOnConsecutiveCalls($view1, $view2); - - $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); - $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); + $list = new ArrayChoiceList([]); + + $view1 = $this->factory->createView($list, null, null, null, null, $attr1); + $view2 = $this->factory->createView($list, null, null, null, null, $attr2); + + $this->assertNotSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function provideSameChoices() diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 18cf4daa0cb3..25fb551df7ce 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -16,10 +16,10 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; class DefaultChoiceListFactoryTest extends TestCase { @@ -194,7 +194,7 @@ function ($object) { return $object->value; } public function testCreateFromLoader() { - $loader = $this->createMock(ChoiceLoaderInterface::class); + $loader = new ArrayChoiceLoader(); $list = $this->factory->createListFromLoader($loader); @@ -203,7 +203,7 @@ public function testCreateFromLoader() public function testCreateFromLoaderWithValues() { - $loader = $this->createMock(ChoiceLoaderInterface::class); + $loader = new ArrayChoiceLoader(); $value = function () {}; $list = $this->factory->createListFromLoader($loader, $value); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 16969f3288f7..2a7884d0c59e 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; +use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; -use Symfony\Component\Form\ChoiceList\View\ChoiceListView; +use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; +use Symfony\Component\Form\ChoiceList\View\ChoiceView; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; use Symfony\Component\PropertyAccess\PropertyPath; /** @@ -26,11 +25,6 @@ */ class PropertyAccessDecoratorTest extends TestCase { - /** - * @var MockObject&ChoiceListFactoryInterface - */ - private $decoratedFactory; - /** * @var PropertyAccessDecorator */ @@ -38,50 +32,29 @@ class PropertyAccessDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->createMock(ChoiceListFactoryInterface::class); - $this->factory = new PropertyAccessDecorator($this->decoratedFactory); + $this->factory = new PropertyAccessDecorator(new DefaultChoiceListFactory()); } public function testCreateFromChoicesPropertyPath() { - $choices = [(object) ['property' => 'value']]; + $object = (object) ['property' => 'value']; - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($choices, $callback) { - return new ArrayChoiceList(array_map($callback, $choices)); - }); - - $this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, 'property')->getChoices()); + $this->assertSame(['value' => $object], $this->factory->createListFromChoices([$object], 'property')->getChoices()); } public function testCreateFromChoicesPropertyPathInstance() { - $choices = [(object) ['property' => 'value']]; - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($choices, $callback) { - return new ArrayChoiceList(array_map($callback, $choices)); - }); + $object = (object) ['property' => 'value']; - $this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))->getChoices()); + $this->assertSame(['value' => $object], $this->factory->createListFromChoices([$object], new PropertyPath('property'))->getChoices()); } public function testCreateFromLoaderPropertyPath() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($loader, $callback) { - return new ArrayChoiceList((array) $callback((object) ['property' => 'value'])); - }); + $object = (object) ['property' => 'value']; + $loader = new ArrayChoiceLoader([$object]); - $this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, 'property')->getChoices()); + $this->assertSame(['value' => $object], $this->factory->createListFromLoader($loader, 'property')->getChoices()); } // https://github.com/symfony/symfony/issues/5494 @@ -89,212 +62,122 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() { $choices = [null]; - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($choices, $callback) { - return new ArrayChoiceList(array_map($callback, $choices)); - }); - - $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')->getChoices()); + $this->assertSame(['' => null], $this->factory->createListFromChoices($choices, 'property')->getChoices()); } // https://github.com/symfony/symfony/issues/5494 public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($loader, $callback) { - return new ArrayChoiceList((array) $callback(null)); - }); + $loader = new ArrayChoiceLoader([null]); - $this->assertSame([], $this->factory->createListFromLoader($loader, 'property')->getChoices()); + $this->assertSame(['' => null], $this->factory->createListFromLoader($loader, 'property')->getChoices()); } public function testCreateFromLoaderPropertyPathInstance() { - $loader = $this->createMock(ChoiceLoaderInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($loader, $callback) { - return new ArrayChoiceList((array) $callback((object) ['property' => 'value'])); - }); + $object = (object) ['property' => 'value']; + $loader = new ArrayChoiceLoader([$object]); - $this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, new PropertyPath('property'))->getChoices()); + $this->assertSame(['value' => $object], $this->factory->createListFromLoader($loader, new PropertyPath('property'))->getChoices()); } public function testCreateViewPreferredChoicesAsPropertyPath() { - $list = $this->createMock(ChoiceListInterface::class); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred) { - return new ChoiceListView((array) $preferred((object) ['property' => true])); - }); - - $this->assertSame([true], $this->factory->createView($list, 'property')->choices); + $this->assertEquals([new ChoiceView($object, '0', '0')], $this->factory->createView($list, 'preferred_choice')->choices); + $this->assertEquals([new ChoiceView($object, '0', '0')], $this->factory->createView($list, 'preferred_choice')->preferredChoices); } public function testCreateViewPreferredChoicesAsPropertyPathInstance() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred) { - return new ChoiceListView((array) $preferred((object) ['property' => true])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame([true], $this->factory->createView($list, 'property')->choices); + $this->assertEquals([new ChoiceView($object, '0', '0')], $this->factory->createView($list, new PropertyPath('preferred_choice'))->choices); + $this->assertEquals([new ChoiceView($object, '0', '0')], $this->factory->createView($list, new PropertyPath('preferred_choice'))->preferredChoices); } // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable() { - $list = $this->createMock(ChoiceListInterface::class); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred) { - return new ChoiceListView((array) $preferred((object) ['category' => null])); - }); - - $this->assertSame([false], $this->factory->createView($list, 'category.preferred')->choices); + $this->assertEquals([new ChoiceView($object, '0', '0')], $this->factory->createView($list, new PropertyPath('preferred_choice.property'))->choices); + $this->assertEquals([], $this->factory->createView($list, new PropertyPath('preferred_choice.property'))->preferredChoices); } public function testCreateViewLabelsAsPropertyPath() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label) { - return new ChoiceListView((array) $label((object) ['property' => 'label'])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame(['label'], $this->factory->createView($list, null, 'property')->choices); + $this->assertEquals([new ChoiceView($object, '0', 'foo')], $this->factory->createView($list, null, 'view_label')->choices); } public function testCreateViewLabelsAsPropertyPathInstance() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label) { - return new ChoiceListView((array) $label((object) ['property' => 'label'])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame(['label'], $this->factory->createView($list, null, new PropertyPath('property'))->choices); + $this->assertEquals([new ChoiceView($object, '0', 'foo')], $this->factory->createView($list, null, new PropertyPath('view_label'))->choices); } public function testCreateViewIndicesAsPropertyPath() { - $list = $this->createMock(ChoiceListInterface::class); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index) { - return new ChoiceListView((array) $index((object) ['property' => 'index'])); - }); - - $this->assertSame(['index'], $this->factory->createView($list, null, null, 'property')->choices); + $this->assertEquals(['key' => new ChoiceView($object, '0', '0')], $this->factory->createView($list, null, null, 'view_index')->choices); } public function testCreateViewIndicesAsPropertyPathInstance() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index) { - return new ChoiceListView((array) $index((object) ['property' => 'index'])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame(['index'], $this->factory->createView($list, null, null, new PropertyPath('property'))->choices); + $this->assertEquals(['key' => new ChoiceView($object, '0', '0')], $this->factory->createView($list, null, null, new PropertyPath('view_index'))->choices); } public function testCreateViewGroupsAsPropertyPath() { - $list = $this->createMock(ChoiceListInterface::class); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return new ChoiceListView((array) $groupBy((object) ['property' => 'group'])); - }); - - $this->assertSame(['group'], $this->factory->createView($list, null, null, null, 'property')->choices); + $this->assertEquals(['bar' => new ChoiceGroupView('bar', [new ChoiceView($object, '0', '0')])], $this->factory->createView($list, null, null, null, 'view_group')->choices); } public function testCreateViewGroupsAsPropertyPathInstance() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return new ChoiceListView((array) $groupBy((object) ['property' => 'group'])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame(['group'], $this->factory->createView($list, null, null, null, new PropertyPath('property'))->choices); + $this->assertEquals(['bar' => new ChoiceGroupView('bar', [new ChoiceView($object, '0', '0')])], $this->factory->createView($list, null, null, null, new PropertyPath('view_group'))->choices); } // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return new ChoiceListView((array) $groupBy((object) ['group' => null])); - }); + $list = new ArrayChoiceList([]); $this->assertSame([], $this->factory->createView($list, null, null, null, 'group.name')->choices); } public function testCreateViewAttrAsPropertyPath() { - $list = $this->createMock(ChoiceListInterface::class); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { - return new ChoiceListView((array) $attr((object) ['property' => 'attr'])); - }); - - $this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, 'property')->choices); + $this->assertEquals([new ChoiceView($object, '0', '0', ['baz' => 'foobar'])], $this->factory->createView($list, null, null, null, null, 'view_attribute')->choices); } public function testCreateViewAttrAsPropertyPathInstance() { - $list = $this->createMock(ChoiceListInterface::class); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { - return new ChoiceListView((array) $attr((object) ['property' => 'attr'])); - }); + $object = (object) ['preferred_choice' => true, 'view_label' => 'foo', 'view_index' => 'key', 'view_group' => 'bar', 'view_attribute' => ['baz' => 'foobar']]; + $list = new ArrayChoiceList([$object]); - $this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, new PropertyPath('property'))->choices); + $this->assertEquals([new ChoiceView($object, '0', '0', ['baz' => 'foobar'])], $this->factory->createView($list, null, null, null, null, new PropertyPath('view_attribute'))->choices); } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 0c74ae1896d7..6f30d0896e1b 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -11,155 +11,129 @@ namespace Symfony\Component\Form\Tests\ChoiceList; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; /** * @author Bernhard Schussek */ class LazyChoiceListTest extends TestCase { - /** - * @var LazyChoiceList - */ - private $list; - - /** - * @var MockObject&ChoiceListInterface - */ - private $loadedList; - - /** - * @var MockObject&ChoiceLoaderInterface - */ - private $loader; - - /** - * @var \Closure - */ - private $value; - - protected function setUp(): void - { - $this->loadedList = $this->createMock(ChoiceListInterface::class); - $this->loader = $this->createMock(ChoiceLoaderInterface::class); - $this->value = function () {}; - $this->list = new LazyChoiceList($this->loader, $this->value); - } - public function testGetChoiceLoadersLoadsLoadedListOnFirstCall() { - $this->loader->expects($this->exactly(2)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - // The same list is returned by the loader - $this->loadedList->expects($this->exactly(2)) - ->method('getChoices') - ->willReturn(['RESULT']); - - $this->assertSame(['RESULT'], $this->list->getChoices()); - $this->assertSame(['RESULT'], $this->list->getChoices()); + $choices = ['RESULT']; + $calls = 0; + $list = new LazyChoiceList(new ArrayChoiceLoader($choices), function ($choice) use ($choices, &$calls) { + ++$calls; + + return array_search($choice, $choices); + }); + + $this->assertSame(['RESULT'], $list->getChoices()); + $this->assertSame(['RESULT'], $list->getChoices()); + $this->assertSame(1, $calls); } public function testGetValuesLoadsLoadedListOnFirstCall() { - $this->loader->expects($this->exactly(2)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - // The same list is returned by the loader - $this->loadedList->expects($this->exactly(2)) - ->method('getValues') - ->willReturn(['RESULT']); - - $this->assertSame(['RESULT'], $this->list->getValues()); - $this->assertSame(['RESULT'], $this->list->getValues()); + $calls = 0; + $list = new LazyChoiceList(new ArrayChoiceLoader(['RESULT']), function ($choice) use (&$calls) { + ++$calls; + + return $choice; + }); + + $this->assertSame(['RESULT'], $list->getValues()); + $this->assertSame(['RESULT'], $list->getValues()); + $this->assertSame(1, $calls); } public function testGetStructuredValuesLoadsLoadedListOnFirstCall() { - $this->loader->expects($this->exactly(2)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - // The same list is returned by the loader - $this->loadedList->expects($this->exactly(2)) - ->method('getStructuredValues') - ->willReturn(['RESULT']); - - $this->assertSame(['RESULT'], $this->list->getStructuredValues()); - $this->assertSame(['RESULT'], $this->list->getStructuredValues()); + $calls = 0; + $list = new LazyChoiceList(new ArrayChoiceLoader(['RESULT']), function ($choice) use (&$calls) { + ++$calls; + + return $choice; + }); + + $this->assertSame(['RESULT'], $list->getStructuredValues()); + $this->assertSame(['RESULT'], $list->getStructuredValues()); + $this->assertSame(1, $calls); } public function testGetOriginalKeysLoadsLoadedListOnFirstCall() { - $this->loader->expects($this->exactly(2)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - // The same list is returned by the loader - $this->loadedList->expects($this->exactly(2)) - ->method('getOriginalKeys') - ->willReturn(['RESULT']); - - $this->assertSame(['RESULT'], $this->list->getOriginalKeys()); - $this->assertSame(['RESULT'], $this->list->getOriginalKeys()); + $calls = 0; + $choices = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'baz', + ]; + $list = new LazyChoiceList(new ArrayChoiceLoader($choices), function ($choice) use (&$calls) { + ++$calls; + + return $choice; + }); + + $this->assertSame(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $list->getOriginalKeys()); + $this->assertSame(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $list->getOriginalKeys()); + $this->assertSame(3, $calls); } public function testGetChoicesForValuesForwardsCallIfListNotLoaded() { - $this->loader->expects($this->exactly(2)) - ->method('loadChoicesForValues') - ->with(['a', 'b']) - ->willReturn(['RESULT']); - - $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); - $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); + $calls = 0; + $choices = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'baz', + ]; + $list = new LazyChoiceList(new ArrayChoiceLoader($choices), function ($choice) use ($choices, &$calls) { + ++$calls; + + return array_search($choice, $choices); + }); + + $this->assertSame(['foo', 'bar'], $list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['foo', 'bar'], $list->getChoicesForValues(['a', 'b'])); + $this->assertSame(3, $calls); } public function testGetChoicesForValuesUsesLoadedList() { - $this->loader->expects($this->exactly(1)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - $this->loader->expects($this->exactly(2)) - ->method('loadChoicesForValues') - ->with(['a', 'b']) - ->willReturn(['RESULT']); + $choices = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'baz', + ]; + $list = new LazyChoiceList(new ArrayChoiceLoader($choices), function ($choice) use ($choices) { + return array_search($choice, $choices); + }); // load choice list - $this->list->getChoices(); + $list->getChoices(); - $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); - $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['foo', 'bar'], $list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['foo', 'bar'], $list->getChoicesForValues(['a', 'b'])); } public function testGetValuesForChoicesUsesLoadedList() { - $this->loader->expects($this->exactly(1)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - $this->loader->expects($this->exactly(2)) - ->method('loadValuesForChoices') - ->with(['a', 'b']) - ->willReturn(['RESULT']); + $choices = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'baz', + ]; + $list = new LazyChoiceList(new ArrayChoiceLoader($choices), function ($choice) use ($choices) { + return array_search($choice, $choices); + }); // load choice list - $this->list->getChoices(); + $list->getChoices(); - $this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b'])); - $this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b'])); + $this->assertSame(['a', 'b'], $list->getValuesForChoices(['foo', 'bar'])); + $this->assertSame(['a', 'b'], $list->getValuesForChoices(['foo', 'bar'])); } } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index a6fd1a1e93c7..7f8548e7a415 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -11,28 +11,50 @@ namespace Symfony\Component\Form\Tests; +use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\Exception\AlreadySubmittedException; use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; -use Symfony\Component\Form\Form; +use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormErrorIterator; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; +use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\Forms; use Symfony\Component\Form\FormView; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\ResolvedFormTypeInterface; -use Symfony\Component\Form\SubmitButton; use Symfony\Component\Form\SubmitButtonBuilder; use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; -use Symfony\Component\Form\Util\InheritDataAwareIterator; +use Symfony\Component\Form\Tests\Fixtures\Map; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; -class CompoundFormTest extends AbstractFormTest +class CompoundFormTest extends TestCase { + /** + * @var FormFactoryInterface + */ + private $factory; + + /** + * @var FormInterface + */ + private $form; + + protected function setUp(): void + { + $this->factory = new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())); + $this->form = $this->createForm(); + } + public function testValidIfAllChildrenAreValid() { $this->form->add($this->getBuilder('firstName')->getForm()); @@ -66,7 +88,7 @@ public function testDisabledFormsValidEvenIfChildrenInvalid() $form = $this->getBuilder('person') ->setDisabled(true) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->add($this->getBuilder('name')) ->getForm(); @@ -131,10 +153,12 @@ public function testClearMissingFlagIsForwarded() $personForm->add($firstNameForm); $lastNameForm = $this->createForm('lastName', false); - $lastNameForm->setData('last name'); $personForm->add($lastNameForm); $this->form->add($personForm); + + $this->form->setData(['person' => ['lastName' => 'last name']]); + $this->form->submit(['person' => ['firstName' => 'foo']], false); $this->assertTrue($firstNameForm->isSubmitted()); @@ -158,10 +182,10 @@ public function testCloneChildren() public function testNotEmptyIfChildNotEmpty() { $child = $this->createForm('name', false); - $child->setData('foo'); $this->form->setData(null); $this->form->add($child); + $child->setData('foo'); $this->assertFalse($this->form->isEmpty()); } @@ -178,101 +202,72 @@ public function testAdd() public function testAddUsingNameAndType() { - $child = $this->getBuilder('foo')->getForm(); + $this->form->add('foo', TextType::class); - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'bar' => 'baz', - 'auto_initialize' => false, - ]) - ->willReturn($child); + $this->assertTrue($this->form->has('foo')); - $this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); + $child = $this->form->get('foo'); - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); + $this->assertInstanceOf(TextType::class, $child->getConfig()->getType()->getInnerType()); $this->assertSame(['foo' => $child], $this->form->all()); } public function testAddUsingIntegerNameAndType() { - $child = $this->getBuilder('0')->getForm(); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('0', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'bar' => 'baz', - 'auto_initialize' => false, - ]) - ->willReturn($child); - // in order to make casting unnecessary - $this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); + $this->form->add(0, TextType::class); $this->assertTrue($this->form->has(0)); - $this->assertSame($this->form, $child->getParent()); + + $child = $this->form->get(0); + + $this->assertInstanceOf(TextType::class, $child->getConfig()->getType()->getInnerType()); $this->assertSame([0 => $child], $this->form->all()); } public function testAddWithoutType() { - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->willReturn($child); - $this->form->add('foo'); $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); + + $child = $this->form->get('foo'); + + $this->assertInstanceOf(TextType::class, $child->getConfig()->getType()->getInnerType()); $this->assertSame(['foo' => $child], $this->form->all()); } public function testAddUsingNameButNoType() { - $this->form = $this->getBuilder('name', null, \stdClass::class) + $this->form = $this->getBuilder('name', \stdClass::class) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createForProperty') - ->with(\stdClass::class, 'foo') - ->willReturn($child); - $this->form->add('foo'); $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); + + $child = $this->form->get('foo'); + + $this->assertInstanceOf(TextType::class, $child->getConfig()->getType()->getInnerType()); $this->assertSame(['foo' => $child], $this->form->all()); } public function testAddUsingNameButNoTypeAndOptions() { - $this->form = $this->getBuilder('name', null, \stdClass::class) + $this->form = $this->getBuilder('name', \stdClass::class) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); - $child = $this->getBuilder('foo')->getForm(); + $this->form->add('foo'); - $this->factory->expects($this->once()) - ->method('createForProperty') - ->with(\stdClass::class, 'foo', null, [ - 'bar' => 'baz', - 'auto_initialize' => false, - ]) - ->willReturn($child); + $this->assertTrue($this->form->has('foo')); - $this->form->add('foo', null, ['bar' => 'baz']); + $child = $this->form->get('foo'); - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); + $this->assertInstanceOf(TextType::class, $child->getConfig()->getType()->getInnerType()); $this->assertSame(['foo' => $child], $this->form->all()); } @@ -340,60 +335,55 @@ public function testIterator() public function testAddMapsViewDataToFormIfInitialized() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer([ - '' => '', - 'foo' => 'bar', - ])) - ->setData('foo') + ->setDataMapper(new PropertyPathMapper()) + ->setData(['child' => 'foo']) ->getForm(); - $child = $this->getBuilder()->getForm(); - $mapper->expects($this->once()) - ->method('mapDataToForms') - ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) - ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { - $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); - $this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); - }); + $child = $this->getBuilder('child')->getForm(); + + $this->assertNull($child->getData()); $form->initialize(); $form->add($child); + + $this->assertSame('foo', $child->getData()); } public function testAddDoesNotMapViewDataToFormIfNotInitialized() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $child = $this->getBuilder()->getForm(); - $mapper->expects($this->never()) - ->method('mapDataToForms'); $form->add($child); + + $this->assertNull($form->getData()); + $this->assertNull($form->getNormData()); + $this->assertNull($form->getViewData()); } public function testAddDoesNotMapViewDataToFormIfInheritData() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) - ->setInheritData(true) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); - $child = $this->getBuilder()->getForm(); - $mapper->expects($this->never()) - ->method('mapDataToForms'); + $child = $this->getBuilder() + ->setInheritData(true) + ->getForm(); $form->initialize(); $form->add($child); + + $this->assertNull($form->getData()); + $this->assertNull($form->getNormData()); + $this->assertNull($form->getViewData()); } public function testSetDataSupportsDynamicAdditionAndRemovalOfChildren() @@ -408,7 +398,7 @@ public function testSetDataSupportsDynamicAdditionAndRemovalOfChildren() $childToBeRemoved = $this->createForm('removed', false); $childToBeAdded = $this->createForm('added', false); - $child = $this->getBuilder('child', new EventDispatcher()) + $child = $this->getBuilder('child') ->setCompound(true) ->setDataMapper(new PropertyPathMapper()) ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($form, $childToBeAdded) { @@ -429,28 +419,24 @@ public function testSetDataSupportsDynamicAdditionAndRemovalOfChildren() public function testSetDataMapsViewDataToChildren() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer([ - '' => '', - 'foo' => 'bar', - ])) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $form->add($child1 = $this->getBuilder('firstName')->getForm()); $form->add($child2 = $this->getBuilder('lastName')->getForm()); - $mapper->expects($this->once()) - ->method('mapDataToForms') - ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) - ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { - $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); - $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); - }); + $this->assertNull($child1->getData()); + $this->assertNull($child2->getData()); - $form->setData('foo'); + $form->setData([ + 'firstName' => 'foo', + 'lastName' => 'bar', + ]); + + $this->assertSame('foo', $child1->getData()); + $this->assertSame('bar', $child2->getData()); } public function testSetDataDoesNotMapViewDataToChildrenWithLockedSetData() @@ -503,59 +489,49 @@ public function testSubmitSupportsDynamicAdditionAndRemovalOfChildren() public function testSubmitMapsSubmittedChildrenOntoExistingViewData() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer([ - '' => '', - 'foo' => 'bar', - ])) - ->setData('foo') + ->setDataMapper(new PropertyPathMapper()) + ->setData([ + 'firstName' => null, + 'lastName' => null, + ]) ->getForm(); $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); - $mapper->expects($this->once()) - ->method('mapFormsToData') - ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), 'bar') - ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { - $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); - $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); - $this->assertEquals('Bernhard', $child1->getData()); - $this->assertEquals('Schussek', $child2->getData()); - }); + $this->assertSame(['firstName' => null, 'lastName' => null], $form->getData()); $form->submit([ 'firstName' => 'Bernhard', 'lastName' => 'Schussek', ]); + + $this->assertSame(['firstName' => 'Bernhard', 'lastName' => 'Schussek'], $form->getData()); } public function testMapFormsToDataIsNotInvokedIfInheritData() { - $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) - ->setInheritData(true) - ->addViewTransformer(new FixedDataTransformer([ - '' => '', - 'foo' => 'bar', - ])) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); - $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); - $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); - - $mapper->expects($this->never()) - ->method('mapFormsToData'); + $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->setInheritData(true)->getForm()); + $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->setInheritData(true)->getForm()); $form->submit([ 'firstName' => 'Bernhard', 'lastName' => 'Schussek', ]); + + $this->assertNull($child1->getData()); + $this->assertNull($child1->getNormData()); + $this->assertNull($child1->getViewData()); + $this->assertNull($child2->getData()); + $this->assertNull($child2->getNormData()); + $this->assertNull($child2->getViewData()); } /* @@ -563,11 +539,10 @@ public function testMapFormsToDataIsNotInvokedIfInheritData() */ public function testSubmitRestoresViewDataIfCompoundAndEmpty() { - $mapper = $this->getDataMapper(); $object = new \stdClass(); - $form = $this->getBuilder('name', null, 'stdClass') + $form = $this->getBuilder('name', \stdClass::class) ->setCompound(true) - ->setDataMapper($mapper) + ->setDataMapper(new PropertyPathMapper()) ->setData($object) ->getForm(); @@ -578,28 +553,21 @@ public function testSubmitRestoresViewDataIfCompoundAndEmpty() public function testSubmitMapsSubmittedChildrenOntoEmptyData() { - $mapper = $this->getDataMapper(); - $object = new \stdClass(); + $object = new Map(); $form = $this->getBuilder() ->setCompound(true) - ->setDataMapper($mapper) + ->setDataMapper(new PropertyPathMapper()) ->setEmptyData($object) ->setData(null) ->getForm(); $form->add($child = $this->getBuilder('name')->setCompound(false)->getForm()); - $mapper->expects($this->once()) - ->method('mapFormsToData') - ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), $object) - ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { - $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); - $this->assertSame(['name' => $child], iterator_to_array($iterator)); - }); - $form->submit([ 'name' => 'Bernhard', ]); + + $this->assertSame('Bernhard', $object['name']); } public function requestMethodProvider() @@ -644,7 +612,7 @@ public function testSubmitPostOrPutRequest($method) $form = $this->getBuilder('author') ->setMethod($method) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setRequestHandler(new HttpFoundationRequestHandler()) ->getForm(); $form->add($this->getBuilder('name')->getForm()); @@ -691,7 +659,7 @@ public function testSubmitPostOrPutRequestWithEmptyRootFormName($method) $form = $this->getBuilder('') ->setMethod($method) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setRequestHandler(new HttpFoundationRequestHandler()) ->getForm(); $form->add($this->getBuilder('name')->getForm()); @@ -731,7 +699,7 @@ public function testSubmitPostOrPutRequestWithSingleChildForm($method) 'REQUEST_METHOD' => $method, ]); - $form = $this->getBuilder('image', null, null, ['allow_file_upload' => true]) + $form = $this->getBuilder('image', null, ['allow_file_upload' => true]) ->setMethod($method) ->setRequestHandler(new HttpFoundationRequestHandler()) ->getForm(); @@ -790,7 +758,7 @@ public function testSubmitGetRequest() $form = $this->getBuilder('author') ->setMethod('GET') ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setRequestHandler(new HttpFoundationRequestHandler()) ->getForm(); $form->add($this->getBuilder('firstName')->getForm()); @@ -817,7 +785,7 @@ public function testSubmitGetRequestWithEmptyRootFormName() $form = $this->getBuilder('') ->setMethod('GET') ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setRequestHandler(new HttpFoundationRequestHandler()) ->getForm(); $form->add($this->getBuilder('firstName')->getForm()); @@ -966,9 +934,9 @@ public function testCreateViewWithChildren() ->method('createView') ->willReturn($field2View); - $this->form = $this->getBuilder('form', null, null, $options) + $this->form = $this->getBuilder('form', null, $options) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setType($type) ->getForm(); $this->form->add($field1); @@ -1002,20 +970,11 @@ public function testNoClickedButtonBeforeSubmission() public function testNoClickedButton() { - $button = $this->getMockBuilder(SubmitButton::class) - ->setConstructorArgs([new SubmitButtonBuilder('submit')]) - ->setMethods(['isClicked']) - ->getMock(); - - $button->expects($this->any()) - ->method('isClicked') - ->willReturn(false); - $parentForm = $this->getBuilder('parent')->getForm(); $nestedForm = $this->getBuilder('nested')->getForm(); $this->form->setParent($parentForm); - $this->form->add($button); + $this->form->add($this->factory->create(SubmitType::class)); $this->form->add($nestedForm); $this->form->submit([]); @@ -1024,55 +983,41 @@ public function testNoClickedButton() public function testClickedButton() { - $button = $this->getMockBuilder(SubmitButton::class) - ->setConstructorArgs([new SubmitButtonBuilder('submit')]) - ->setMethods(['isClicked']) - ->getMock(); - - $button->expects($this->any()) - ->method('isClicked') - ->willReturn(true); + $button = $this->factory->create(SubmitType::class); $this->form->add($button); - $this->form->submit([]); + $this->form->submit(['submit' => '']); $this->assertSame($button, $this->form->getClickedButton()); } public function testClickedButtonFromNestedForm() { - $button = $this->getBuilder('submit')->getForm(); - - $nestedForm = $this->getMockBuilder(Form::class) - ->setConstructorArgs([$this->getBuilder('nested')]) - ->setMethods(['getClickedButton']) - ->getMock(); + $button = $this->factory->create(SubmitType::class); - $nestedForm->expects($this->any()) - ->method('getClickedButton') - ->willReturn($button); + $nestedForm = $this->createForm('nested'); + $nestedForm->add($button); $this->form->add($nestedForm); - $this->form->submit([]); + $this->form->submit([ + 'nested' => [ + 'submit' => '', + ], + ]); $this->assertSame($button, $this->form->getClickedButton()); } public function testClickedButtonFromParentForm() { - $button = $this->getBuilder('submit')->getForm(); - - $parentForm = $this->getMockBuilder(Form::class) - ->setConstructorArgs([$this->getBuilder('parent')]) - ->setMethods(['getClickedButton']) - ->getMock(); - - $parentForm->expects($this->any()) - ->method('getClickedButton') - ->willReturn($button); + $button = $this->factory->create(SubmitType::class); - $this->form->setParent($parentForm); - $this->form->submit([]); + $parentForm = $this->createForm(''); + $parentForm->add($this->form); + $parentForm->add($button); + $parentForm->submit([ + 'submit' => '', + ]); $this->assertSame($button, $this->form->getClickedButton()); } @@ -1102,7 +1047,7 @@ public function testDisabledButtonIsNotSubmitted() public function testArrayTransformationFailureOnSubmit() { $this->form->add($this->getBuilder('foo')->setCompound(false)->getForm()); - $this->form->add($this->getBuilder('bar', null, null, ['multiple' => false])->setCompound(false)->getForm()); + $this->form->add($this->getBuilder('bar', null, ['multiple' => false])->setCompound(false)->getForm()); $this->form->submit([ 'foo' => ['foo'], @@ -1130,17 +1075,22 @@ public function testFileUpload() $this->assertNull($this->form->get('bar')->getData()); } - protected function createForm(string $name = 'name', bool $compound = true): FormInterface + private function createForm(string $name = 'name', bool $compound = true): FormInterface { $builder = $this->getBuilder($name); if ($compound) { $builder ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ; } return $builder->getForm(); } + + private function getBuilder(string $name = 'name', string $dataClass = null, array $options = []): FormBuilder + { + return new FormBuilder($name, $dataClass, new EventDispatcher(), $this->factory, $options); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php index f6d4226e5bef..e3f101a8aac9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php @@ -15,19 +15,21 @@ use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; -class BaseDateTimeTransformerTest extends TestCase +abstract class BaseDateTimeTransformerTest extends TestCase { public function testConstructFailsIfInputTimezoneIsInvalid() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('this_timezone_does_not_exist'); - $this->getMockBuilder(BaseDateTimeTransformer::class)->setConstructorArgs(['this_timezone_does_not_exist'])->getMock(); + $this->createDateTimeTransformer('this_timezone_does_not_exist'); } public function testConstructFailsIfOutputTimezoneIsInvalid() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('that_timezone_does_not_exist'); - $this->getMockBuilder(BaseDateTimeTransformer::class)->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock(); + $this->createDateTimeTransformer(null, 'that_timezone_does_not_exist'); } + + abstract protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php index 307667b1f75f..30be21e590de 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php @@ -12,43 +12,27 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; +use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; class DataTransformerChainTest extends TestCase { public function testTransform() { - $transformer1 = $this->createMock(DataTransformerInterface::class); - $transformer1->expects($this->once()) - ->method('transform') - ->with($this->identicalTo('foo')) - ->willReturn('bar'); - $transformer2 = $this->createMock(DataTransformerInterface::class); - $transformer2->expects($this->once()) - ->method('transform') - ->with($this->identicalTo('bar')) - ->willReturn('baz'); - - $chain = new DataTransformerChain([$transformer1, $transformer2]); + $chain = new DataTransformerChain([ + new FixedDataTransformer(['foo' => 'bar']), + new FixedDataTransformer(['bar' => 'baz']), + ]); $this->assertEquals('baz', $chain->transform('foo')); } public function testReverseTransform() { - $transformer2 = $this->createMock(DataTransformerInterface::class); - $transformer2->expects($this->once()) - ->method('reverseTransform') - ->with($this->identicalTo('foo')) - ->willReturn('bar'); - $transformer1 = $this->createMock(DataTransformerInterface::class); - $transformer1->expects($this->once()) - ->method('reverseTransform') - ->with($this->identicalTo('bar')) - ->willReturn('baz'); - - $chain = new DataTransformerChain([$transformer1, $transformer2]); + $chain = new DataTransformerChain([ + new FixedDataTransformer(['baz' => 'bar']), + new FixedDataTransformer(['bar' => 'foo']), + ]); $this->assertEquals('baz', $chain->reverseTransform('foo')); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php index 3ebfb9d1b51f..3aafbec88a4e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; -class DateTimeToArrayTransformerTest extends TestCase +class DateTimeToArrayTransformerTest extends BaseDateTimeTransformerTest { public function testTransform() { @@ -535,4 +535,9 @@ public function testReverseTransformWithEmptyStringSecond() 'second' => '', ]); } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToArrayTransformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php index 2e4b4ba7e696..6e6e66afb186 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php @@ -11,12 +11,12 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer; use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; -class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase +class DateTimeToHtml5LocalDateTimeTransformerTest extends BaseDateTimeTransformerTest { use DateTimeEqualsTrait; @@ -115,4 +115,9 @@ public function testReverseTransformExpectsValidDateString() $transformer->reverseTransform('2010-2010-2010'); } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToHtml5LocalDateTimeTransformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index cde7cd531a89..ece8df76b231 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -11,13 +11,13 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; use Symfony\Component\Intl\Util\IntlTestHelper; -class DateTimeToLocalizedStringTransformerTest extends TestCase +class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTest { use DateTimeEqualsTrait; @@ -372,4 +372,9 @@ public function testReverseTransformWrapsIntlErrorsWithExceptionsAndErrorLevel() $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform('12345'); } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToLocalizedStringTransformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index 0c28ac50951c..eccaa22a136f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -11,12 +11,12 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; -class DateTimeToRfc3339TransformerTest extends TestCase +class DateTimeToRfc3339TransformerTest extends BaseDateTimeTransformerTest { use DateTimeEqualsTrait; @@ -143,4 +143,9 @@ public function invalidDateStringProvider() 'RSS format' => ['Sat, 01 May 2010 04:05:00 +0000'], ]; } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToRfc3339Transformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index dc01ba15503d..a7299e67ba23 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; -class DateTimeToStringTransformerTest extends TestCase +class DateTimeToStringTransformerTest extends BaseDateTimeTransformerTest { public function dataProvider(): array { @@ -170,4 +170,9 @@ public function testReverseTransformWithNonExistingDate() $reverseTransformer->reverseTransform('2010-04-31'); } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToStringTransformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php index b02be9a168b8..7a84153a7383 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; -use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; -class DateTimeToTimestampTransformerTest extends TestCase +class DateTimeToTimestampTransformerTest extends BaseDateTimeTransformerTest { public function testTransform() { @@ -114,4 +114,9 @@ public function testReverseTransformExpectsValidTimestamp() $reverseTransformer->reverseTransform('2010-2010-2010'); } + + protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer + { + return new DateTimeToTimestampTransformer($inputTimezone, $outputTimezone); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index c4817538d073..95f1fe2db314 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -220,17 +220,7 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithN public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed() { - $formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL); - $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 1); - $formatter->setAttribute(\NumberFormatter::GROUPING_USED, false); - - $transformer = $this->getMockBuilder(PercentToLocalizedStringTransformer::class) - ->setMethods(['getNumberFormatter']) - ->setConstructorArgs([1, 'integer']) - ->getMock(); - $transformer->expects($this->any()) - ->method('getNumberFormatter') - ->willReturn($formatter); + $transformer = new PercentToLocalizedStringTransformerWithoutGrouping(1, 'integer'); $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); @@ -296,3 +286,14 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() $transformer->reverseTransform("12\xc2\xa0345,678foo"); } } + +class PercentToLocalizedStringTransformerWithoutGrouping extends PercentToLocalizedStringTransformer +{ + protected function getNumberFormatter(): \NumberFormatter + { + $formatter = parent::getNumberFormatter(); + $formatter->setAttribute(\NumberFormatter::GROUPING_USED, false); + + return $formatter; + } +} diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php index 5db5e9e8ab92..5ca526743068 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\RequestHandlerInterface; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\Translation\IdentityTranslator; class FileTypeTest extends BaseTypeTest { @@ -25,10 +25,7 @@ class FileTypeTest extends BaseTypeTest protected function getExtensions() { - $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->any())->method('trans')->willReturnArgument(0); - - return array_merge(parent::getExtensions(), [new CoreExtension(null, null, $translator)]); + return array_merge(parent::getExtensions(), [new CoreExtension(null, null, new IdentityTranslator())]); } // https://github.com/symfony/symfony/pull/5028 @@ -210,7 +207,7 @@ public function testFailedFileUploadIsTurnedIntoFormErrorUsingHttpFoundationRequ $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[0]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[0]->getMessage()); } } @@ -235,7 +232,7 @@ public function testFailedFileUploadIsTurnedIntoFormErrorUsingNativeRequestHandl $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[0]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[0]->getMessage()); } } @@ -261,8 +258,8 @@ public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsin } else { $this->assertFalse($form->isValid()); $this->assertCount(2, $form->getErrors()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[0]->getMessage()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[1]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[0]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[1]->getMessage()); } } @@ -299,8 +296,8 @@ public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsin } else { $this->assertFalse($form->isValid()); $this->assertCount(2, $form->getErrors()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[0]->getMessage()); - $this->assertSame($expectedErrorMessage, $form->getErrors()[1]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[0]->getMessage()); + $this->assertMatchesRegularExpression($expectedErrorMessage, $form->getErrors()[1]->getMessage()); } } @@ -308,13 +305,13 @@ public function uploadFileErrorCodes() { return [ 'no error' => [\UPLOAD_ERR_OK, null], - 'upload_max_filesize ini directive' => [\UPLOAD_ERR_INI_SIZE, 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.'], - 'MAX_FILE_SIZE from form' => [\UPLOAD_ERR_FORM_SIZE, 'The file is too large.'], - 'partially uploaded' => [\UPLOAD_ERR_PARTIAL, 'The file could not be uploaded.'], - 'no file upload' => [\UPLOAD_ERR_NO_FILE, 'The file could not be uploaded.'], - 'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, 'The file could not be uploaded.'], - 'write failure' => [\UPLOAD_ERR_CANT_WRITE, 'The file could not be uploaded.'], - 'stopped by extension' => [\UPLOAD_ERR_EXTENSION, 'The file could not be uploaded.'], + 'upload_max_filesize ini directive' => [\UPLOAD_ERR_INI_SIZE, '/The file is too large. Allowed maximum size is \d+ \S+\./'], + 'MAX_FILE_SIZE from form' => [\UPLOAD_ERR_FORM_SIZE, '/The file is too large\./'], + 'partially uploaded' => [\UPLOAD_ERR_PARTIAL, '/The file could not be uploaded\./'], + 'no file upload' => [\UPLOAD_ERR_NO_FILE, '/The file could not be uploaded\./'], + 'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, '/The file could not be uploaded\./'], + 'write failure' => [\UPLOAD_ERR_CANT_WRITE, '/The file could not be uploaded\./'], + 'stopped by extension' => [\UPLOAD_ERR_EXTENSION, '/The file could not be uploaded\./'], ]; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php index fc0ae8e45de8..43c94a329be9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php @@ -76,17 +76,18 @@ public function testArrayCsrfToken() public function testMaxPostSizeExceeded() { - $serverParams = $this->createMock(ServerParams::class); - $serverParams - ->expects($this->once()) - ->method('hasPostMaxSizeBeenExceeded') - ->willReturn(true) - ; - $event = new FormEvent($this->form, ['csrf' => 'token']); - $validation = new CsrfValidationListener('csrf', $this->tokenManager, 'unknown', 'Error message', null, null, $serverParams); + $validation = new CsrfValidationListener('csrf', $this->tokenManager, 'unknown', 'Error message', null, null, new ServerParamsPostMaxSizeExceeded()); $validation->preSubmit($event); $this->assertEmpty($this->form->getErrors()); } } + +class ServerParamsPostMaxSizeExceeded extends ServerParams +{ + public function hasPostMaxSizeBeenExceeded(): bool + { + return true; + } +} diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 0adaab003b29..b8e2cf7bcacc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -19,7 +19,7 @@ use Symfony\Component\Form\Test\TypeTestCase; use Symfony\Component\Security\Csrf\CsrfToken; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\Translation\IdentityTranslator; class FormTypeCsrfExtensionTest_ChildType extends AbstractType { @@ -38,32 +38,17 @@ class FormTypeCsrfExtensionTest extends TypeTestCase */ protected $tokenManager; - /** - * @var MockObject&TranslatorInterface - */ - protected $translator; - protected function setUp(): void { $this->tokenManager = $this->createMock(CsrfTokenManagerInterface::class); - $this->translator = $this->createMock(TranslatorInterface::class); - $this->translator->expects($this->any())->method('trans')->willReturnArgument(0); parent::setUp(); } - protected function tearDown(): void - { - $this->tokenManager = null; - $this->translator = null; - - parent::tearDown(); - } - protected function getExtensions() { return array_merge(parent::getExtensions(), [ - new CsrfExtension($this->tokenManager, $this->translator), + new CsrfExtension($this->tokenManager, new IdentityTranslator()), ]); } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php index 9c02d2aff1d3..0ae127d0775d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php @@ -11,10 +11,10 @@ namespace Symfony\Component\Form\Tests\Extension\DataCollector; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension; -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; +use Symfony\Component\Form\Extension\DataCollector\FormDataCollector; +use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; use Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension; class DataCollectorExtensionTest extends TestCase @@ -24,15 +24,9 @@ class DataCollectorExtensionTest extends TestCase */ private $extension; - /** - * @var MockObject&FormDataCollectorInterface - */ - private $dataCollector; - protected function setUp(): void { - $this->dataCollector = $this->createMock(FormDataCollectorInterface::class); - $this->extension = new DataCollectorExtension($this->dataCollector); + $this->extension = new DataCollectorExtension(new FormDataCollector(new FormDataExtractor())); } public function testLoadTypeExtensions() diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index fd5ac459a652..520f707f14df 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -11,18 +11,15 @@ namespace Symfony\Component\Form\Tests\Extension\DataCollector; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\Extension\Core\CoreExtension; -use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\DataCollector\FormDataCollector; -use Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface; +use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormRegistry; @@ -31,31 +28,16 @@ class FormDataCollectorTest extends TestCase { - /** - * @var MockObject&FormDataExtractorInterface - */ - private $dataExtractor; - /** * @var FormDataCollector */ private $dataCollector; - /** - * @var EventDispatcher - */ - private $dispatcher; - /** * @var FormFactory */ private $factory; - /** - * @var PropertyPathMapper - */ - private $dataMapper; - /** * @var Form */ @@ -78,13 +60,10 @@ class FormDataCollectorTest extends TestCase protected function setUp(): void { - $this->dataExtractor = $this->createMock(FormDataExtractorInterface::class); - $this->dataCollector = new FormDataCollector($this->dataExtractor); - $this->dispatcher = new EventDispatcher(); + $this->dataCollector = new FormDataCollector(new FormDataExtractor()); $this->factory = new FormFactory(new FormRegistry([new CoreExtension()], new ResolvedFormTypeFactory())); - $this->dataMapper = new PropertyPathMapper(); $this->form = $this->createForm('name'); - $this->childForm = $this->createForm('child'); + $this->childForm = $this->createChildForm('child'); $this->view = new FormView(); $this->childView = new FormView(); } @@ -93,62 +72,51 @@ public function testBuildPreliminaryFormTree() { $this->form->add($this->childForm); - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractConfiguration') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractDefaultData') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['default_data' => 'foo'], - ['default_data' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractSubmittedData') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['submitted_data' => 'foo'], - ['submitted_data' => 'bar'] - ); - $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); $this->dataCollector->collectSubmittedData($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); $childFormData = [ - 'config' => 'bar', - 'default_data' => 'bar', - 'submitted_data' => 'bar', - 'children' => [], + 'id' => 'name_child', + 'name' => 'child', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->childForm->getConfig()->getOptions(), + 'default_data' => [ + 'norm' => null, + 'view' => '', + ], + 'submitted_data' => [ + 'norm' => null, + 'view' => '', + ], + 'errors' => [], + 'children' => [], ]; $formData = [ - 'config' => 'foo', - 'default_data' => 'foo', - 'submitted_data' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), + 'default_data' => [ + 'norm' => null, + ], + 'submitted_data' => [ + 'norm' => null, + ], + 'errors' => [], 'has_children_error' => false, 'children' => [ 'child' => $childFormData, ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -165,27 +133,21 @@ public function testBuildMultiplePreliminaryFormTrees() $form1 = $this->createForm('form1'); $form2 = $this->createForm('form2'); - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractConfiguration') - ->withConsecutive( - [$form1], - [$form2] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'] - ); - $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectConfiguration($form2); $this->dataCollector->buildPreliminaryFormTree($form1); $form1Data = [ - 'config' => 'foo', + 'id' => 'form1', + 'name' => 'form1', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $form1->getConfig()->getOptions(), 'children' => [], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'form1' => $form1Data, ], @@ -198,11 +160,16 @@ public function testBuildMultiplePreliminaryFormTrees() $this->dataCollector->buildPreliminaryFormTree($form2); $form2Data = [ - 'config' => 'bar', + 'id' => 'form2', + 'name' => 'form2', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $form2->getConfig()->getOptions(), 'children' => [], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'form1' => $form1Data, 'form2' => $form2Data, @@ -217,25 +184,20 @@ public function testBuildMultiplePreliminaryFormTrees() public function testBuildSamePreliminaryFormTreeMultipleTimes() { - $this->dataExtractor - ->method('extractConfiguration') - ->with($this->form) - ->willReturn(['config' => 'foo']); - - $this->dataExtractor - ->method('extractDefaultData') - ->with($this->form) - ->willReturn(['default_data' => 'foo']); - $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); $formData = [ - 'config' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), 'children' => [], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -249,12 +211,20 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes() $this->dataCollector->buildPreliminaryFormTree($this->form); $formData = [ - 'config' => 'foo', - 'default_data' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), + 'default_data' => [ + 'norm' => null, + ], + 'submitted_data' => [], 'children' => [], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -273,7 +243,7 @@ public function testBuildPreliminaryFormTreeWithoutCollectingAnyData() 'children' => [], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -289,50 +259,6 @@ public function testBuildFinalFormTree() $this->form->add($this->childForm); $this->view->children['child'] = $this->childView; - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractConfiguration') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractDefaultData') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['default_data' => 'foo'], - ['default_data' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractSubmittedData') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['submitted_data' => 'foo'], - ['submitted_data' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractViewVariables') - ->withConsecutive( - [$this->view], - [$this->childView] - ) - ->willReturnOnConsecutiveCalls( - ['view_vars' => 'foo'], - ['view_vars' => 'bar'] - ); - $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); $this->dataCollector->collectSubmittedData($this->form); @@ -340,25 +266,53 @@ public function testBuildFinalFormTree() $this->dataCollector->buildFinalFormTree($this->form, $this->view); $childFormData = [ - 'view_vars' => 'bar', - 'config' => 'bar', - 'default_data' => 'bar', - 'submitted_data' => 'bar', + 'id' => 'name_child', + 'name' => 'child', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->childForm->getConfig()->getOptions(), + 'default_data' => [ + 'norm' => null, + 'view' => '', + ], + 'submitted_data' => [ + 'norm' => null, + 'view' => '', + ], + 'errors' => [], + 'view_vars' => [ + 'attr' => [], + 'value' => null, + ], 'children' => [], ]; $formData = [ - 'view_vars' => 'foo', - 'config' => 'foo', - 'default_data' => 'foo', - 'submitted_data' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), + 'default_data' => [ + 'norm' => null, + ], + 'submitted_data' => [ + 'norm' => null, + ], + 'errors' => [], + 'view_vars' => [ + 'attr' => [], + 'value' => null, + ], 'has_children_error' => false, 'children' => [ 'child' => $childFormData, ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -372,9 +326,11 @@ public function testBuildFinalFormTree() public function testSerializeWithFormAddedMultipleTimes() { + $this->expectNotToPerformAssertions(); + $form1 = $this->createForm('form1'); $form2 = $this->createForm('form2'); - $child1 = $this->createForm('child1'); + $child1 = $this->createChildForm('child1'); $form1View = new FormView(); $form2View = new FormView(); @@ -389,66 +345,6 @@ public function testSerializeWithFormAddedMultipleTimes() $form1View->children['child1'] = $child1View; $form2View->children['child1'] = $child1View; - $this->dataExtractor->expects($this->exactly(4)) - ->method('extractConfiguration') - ->withConsecutive( - [$form1], - [$child1], - [$form2], - [$child1] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'], - ['config' => 'foo'], - ['config' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(4)) - ->method('extractDefaultData') - ->withConsecutive( - [$form1], - [$child1], - [$form2], - [$child1] - ) - ->willReturnOnConsecutiveCalls( - ['default_data' => 'foo'], - ['default_data' => 'bar'], - ['default_data' => 'foo'], - ['default_data' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(4)) - ->method('extractSubmittedData') - ->withConsecutive( - [$form1], - [$child1], - [$form2], - [$child1] - ) - ->willReturnOnConsecutiveCalls( - ['submitted_data' => 'foo'], - ['submitted_data' => 'bar'], - ['submitted_data' => 'foo'], - ['submitted_data' => 'bar'] - ); - - $this->dataExtractor->expects($this->exactly(4)) - ->method('extractViewVariables') - ->withConsecutive( - [$form1View], - [$child1View], - [$form2View], - [$child1View] - ) - ->willReturnOnConsecutiveCalls( - ['view_vars' => 'foo'], - ['view_vars' => $child1View->vars], - ['view_vars' => 'foo'], - ['view_vars' => $child1View->vars] - ); - $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectDefaultData($form1); $this->dataCollector->collectSubmittedData($form1); @@ -466,8 +362,8 @@ public function testSerializeWithFormAddedMultipleTimes() public function testFinalFormReliesOnFormViewStructure() { - $this->form->add($child1 = $this->createForm('first')); - $this->form->add($child2 = $this->createForm('second')); + $this->form->add($child1 = $this->createChildForm('first')); + $this->form->add($child2 = $this->createChildForm('second')); $this->view->children['second'] = $this->childView; @@ -488,7 +384,7 @@ public function testFinalFormReliesOnFormViewStructure() ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -509,7 +405,7 @@ public function testFinalFormReliesOnFormViewStructure() ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -528,17 +424,6 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms() $this->view->children['child'] = $this->childView; - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractConfiguration') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'] - ); - // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree $this->dataCollector->collectConfiguration($this->form); @@ -551,13 +436,18 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms() ]; $formData = [ - 'config' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), 'children' => [ 'child' => $childFormData, ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -578,17 +468,6 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc // but associate the two $this->dataCollector->associateFormWithView($this->childForm, $this->childView); - $this->dataExtractor->expects($this->exactly(2)) - ->method('extractConfiguration') - ->withConsecutive( - [$this->form], - [$this->childForm] - ) - ->willReturnOnConsecutiveCalls( - ['config' => 'foo'], - ['config' => 'bar'] - ); - // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree $this->dataCollector->collectConfiguration($this->form); @@ -596,18 +475,28 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc $this->dataCollector->buildFinalFormTree($this->form, $this->view); $childFormData = [ - 'config' => 'bar', + 'id' => 'child', + 'name' => 'child', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->childForm->getConfig()->getOptions(), 'children' => [], ]; $formData = [ - 'config' => 'foo', + 'id' => 'name', + 'name' => 'name', + 'type_class' => FormType::class, + 'synchronized' => true, + 'passed_options' => [], + 'resolved_options' => $this->form->getConfig()->getOptions(), 'children' => [ 'child' => $childFormData, ], ]; - $this->assertSame([ + $this->assertEquals([ 'forms' => [ 'name' => $formData, ], @@ -622,28 +511,15 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc public function testCollectSubmittedDataCountsErrors() { $form1 = $this->createForm('form1'); - $childForm1 = $this->createForm('child1'); + $childForm1 = $this->createChildForm('child1'); $form2 = $this->createForm('form2'); $form1->add($childForm1); - $this->dataExtractor - ->method('extractConfiguration') - ->willReturn([]); - $this->dataExtractor - ->method('extractDefaultData') - ->willReturn([]); - $this->dataExtractor->expects($this->exactly(3)) - ->method('extractSubmittedData') - ->withConsecutive( - [$form1], - [$childForm1], - [$form2] - ) - ->willReturnOnConsecutiveCalls( - ['errors' => ['foo']], - ['errors' => ['bar', 'bam']], - ['errors' => ['baz']] - ); + + $form1->addError(new FormError('foo')); + $childForm1->addError(new FormError('bar')); + $childForm1->addError(new FormError('bam')); + $form2->addError(new FormError('baz')); $this->dataCollector->collectSubmittedData($form1); @@ -658,38 +534,17 @@ public function testCollectSubmittedDataCountsErrors() public function testCollectSubmittedDataExpandedFormsErrors() { - $child1Form = $this->createForm('child1'); - $child11Form = $this->createForm('child11'); - $child2Form = $this->createForm('child2'); - $child21Form = $this->createForm('child21'); + $child1Form = $this->createChildForm('child1', true); + $child11Form = $this->createChildForm('child11'); + $child2Form = $this->createChildForm('child2', true); + $child21Form = $this->createChildForm('child21'); $child1Form->add($child11Form); $child2Form->add($child21Form); $this->form->add($child1Form); $this->form->add($child2Form); - $this->dataExtractor - ->method('extractConfiguration') - ->willReturn([]); - $this->dataExtractor - ->method('extractDefaultData') - ->willReturn([]); - $this->dataExtractor->expects($this->exactly(5)) - ->method('extractSubmittedData') - ->withConsecutive( - [$this->form], - [$child1Form], - [$child11Form], - [$child2Form], - [$child21Form] - ) - ->willReturnOnConsecutiveCalls( - ['errors' => []], - ['errors' => []], - ['errors' => ['foo']], - ['errors' => []], - ['errors' => []] - ); + $child11Form->addError(new FormError('foo')); $this->dataCollector->collectSubmittedData($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); @@ -712,20 +567,18 @@ public function testReset() { $form = $this->createForm('my_form'); - $this->dataExtractor->expects($this->any()) - ->method('extractConfiguration') - ->willReturn([]); - $this->dataExtractor->expects($this->any()) - ->method('extractDefaultData') - ->willReturn([]); - $this->dataExtractor->expects($this->any()) - ->method('extractSubmittedData') - ->with($form) - ->willReturn(['errors' => ['baz']]); - $this->dataCollector->buildPreliminaryFormTree($form); $this->dataCollector->collectSubmittedData($form); + $this->assertNotSame( + [ + 'forms' => [], + 'forms_by_hash' => [], + 'nb_errors' => 0, + ], + $this->dataCollector->getData() + ); + $this->dataCollector->reset(); $this->assertSame( @@ -753,47 +606,45 @@ public function testCollectMissingDataFromChildFormAddedOnFormEvents() ]) ->getForm() ; - $this->dataExtractor->expects($extractConfiguration = $this->exactly(4)) - ->method('extractConfiguration') - ->willReturn([]) - ; - $this->dataExtractor->expects($extractDefaultData = $this->exactly(4)) - ->method('extractDefaultData') - ->willReturnCallback(static function (FormInterface $form) { - // this simulate the call in extractDefaultData() method - // where (if defaultDataSet is false) it fires *_SET_DATA - // events, adding the form related to the configured data - $form->getNormData(); - - return []; - }) - ; - $this->dataExtractor->expects($this->exactly(4)) - ->method('extractSubmittedData') - ->willReturn([]) - ; $this->dataCollector->collectConfiguration($form); - $this->assertSame(2, $extractConfiguration->getInvocationCount(), 'only "root" and "items" forms were collected, the "items" children do not exist yet.'); + $this->dataCollector->buildPreliminaryFormTree($form); + $data = $this->dataCollector->getData(); + $this->assertCount(2, $data['forms_by_hash'], 'only "root" and "items" forms were collected, the "items" children do not exist yet.'); + + foreach ($data['forms_by_hash'] as $formData) { + $this->assertArrayNotHasKey('default_data', $formData); + } $this->dataCollector->collectDefaultData($form); - $this->assertSame(3, $extractConfiguration->getInvocationCount(), 'extracted missing configuration of the "items" children ["0" => foo].'); - $this->assertSame(3, $extractDefaultData->getInvocationCount()); + $this->dataCollector->buildPreliminaryFormTree($form); + $data = $this->dataCollector->getData(); + $this->assertCount(3, $data['forms_by_hash'], 'extracted missing configuration of the "items" children ["0" => foo].'); $this->assertSame(['foo'], $form->get('items')->getData()); + foreach ($data['forms_by_hash'] as $formData) { + $this->assertArrayHasKey('default_data', $formData); + } + $form->submit(['items' => ['foo', 'bar']]); $this->dataCollector->collectSubmittedData($form); - $this->assertSame(4, $extractConfiguration->getInvocationCount(), 'extracted missing configuration of the "items" children ["1" => bar].'); - $this->assertSame(4, $extractDefaultData->getInvocationCount(), 'extracted missing default data of the "items" children ["1" => bar].'); + $this->dataCollector->buildPreliminaryFormTree($form); + $data = $this->dataCollector->getData(); + $this->assertCount(4, $data['forms_by_hash'], 'extracted missing configuration of the "items" children ["1" => bar].'); $this->assertSame(['foo', 'bar'], $form->get('items')->getData()); + + foreach ($data['forms_by_hash'] as $formData) { + $this->assertArrayHasKey('default_data', $formData); + } } - private function createForm($name) + private function createForm(string $name): FormInterface { - $builder = new FormBuilder($name, null, $this->dispatcher, $this->factory); - $builder->setCompound(true); - $builder->setDataMapper($this->dataMapper); + return $this->factory->createNamedBuilder($name)->getForm(); + } - return $builder->getForm(); + private function createChildForm(string $name, bool $compound = false): FormInterface + { + return $this->factory->createNamedBuilder($name, FormType::class, null, ['auto_initialize' => false, 'compound' => $compound])->getForm(); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 10f624b1d823..edbb185f6673 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -11,19 +11,20 @@ namespace Symfony\Component\Form\Tests\Extension\DataCollector; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\DataMapperInterface; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\ResolvedFormTypeInterface; +use Symfony\Component\Form\ResolvedFormType; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; @@ -40,32 +41,15 @@ class FormDataExtractorTest extends TestCase */ private $dataExtractor; - /** - * @var MockObject&EventDispatcherInterface - */ - private $dispatcher; - - /** - * @var MockObject&FormFactoryInterface - */ - private $factory; - protected function setUp(): void { $this->dataExtractor = new FormDataExtractor(); - $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->factory = $this->createMock(FormFactoryInterface::class); } public function testExtractConfiguration() { - $type = $this->createMock(ResolvedFormTypeInterface::class); - $type->expects($this->any()) - ->method('getInnerType') - ->willReturn(new HiddenType()); - $form = $this->createBuilder('name') - ->setType($type) + ->setType(new ResolvedFormType(new HiddenType())) ->getForm(); $this->assertSame([ @@ -80,11 +64,6 @@ public function testExtractConfiguration() public function testExtractConfigurationSortsPassedOptions() { - $type = $this->createMock(ResolvedFormTypeInterface::class); - $type->expects($this->any()) - ->method('getInnerType') - ->willReturn(new HiddenType()); - $options = [ 'b' => 'foo', 'a' => 'bar', @@ -92,7 +71,7 @@ public function testExtractConfigurationSortsPassedOptions() ]; $form = $this->createBuilder('name') - ->setType($type) + ->setType(new ResolvedFormType(new HiddenType())) // passed options are stored in an attribute by // ResolvedTypeDataCollectorProxy ->setAttribute('data_collector/passed_options', $options) @@ -114,11 +93,6 @@ public function testExtractConfigurationSortsPassedOptions() public function testExtractConfigurationSortsResolvedOptions() { - $type = $this->createMock(ResolvedFormTypeInterface::class); - $type->expects($this->any()) - ->method('getInnerType') - ->willReturn(new HiddenType()); - $options = [ 'b' => 'foo', 'a' => 'bar', @@ -126,7 +100,7 @@ public function testExtractConfigurationSortsResolvedOptions() ]; $form = $this->createBuilder('name', $options) - ->setType($type) + ->setType(new ResolvedFormType(new HiddenType())) ->getForm(); $this->assertSame([ @@ -145,21 +119,16 @@ public function testExtractConfigurationSortsResolvedOptions() public function testExtractConfigurationBuildsIdRecursively() { - $type = $this->createMock(ResolvedFormTypeInterface::class); - $type->expects($this->any()) - ->method('getInnerType') - ->willReturn(new HiddenType()); - $grandParent = $this->createBuilder('grandParent') ->setCompound(true) - ->setDataMapper($this->createMock(DataMapperInterface::class)) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $parent = $this->createBuilder('parent') ->setCompound(true) - ->setDataMapper($this->createMock(DataMapperInterface::class)) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $form = $this->createBuilder('name') - ->setType($type) + ->setType(new ResolvedFormType(new HiddenType())) ->getForm(); $grandParent->add($parent); @@ -418,6 +387,6 @@ public function testExtractViewVariables() private function createBuilder(string $name, array $options = []): FormBuilder { - return new FormBuilder($name, null, $this->dispatcher, $this->factory, $options); + return new FormBuilder($name, null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), $options); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php index 7c699f9498b5..13728988cac6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php @@ -11,12 +11,16 @@ namespace Symfony\Component\Form\Tests\Extension\DataCollector\Type; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener; -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\Form\Extension\DataCollector\FormDataCollector; +use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; use Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension; -use Symfony\Component\Form\Test\FormBuilderInterface; +use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\FormEvents; +use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormRegistry; +use Symfony\Component\Form\ResolvedFormTypeFactory; class DataCollectorTypeExtensionTest extends TestCase { @@ -25,15 +29,9 @@ class DataCollectorTypeExtensionTest extends TestCase */ private $extension; - /** - * @var MockObject&FormDataCollectorInterface - */ - private $dataCollector; - protected function setUp(): void { - $this->dataCollector = $this->createMock(FormDataCollectorInterface::class); - $this->extension = new DataCollectorTypeExtension($this->dataCollector); + $this->extension = new DataCollectorTypeExtension(new FormDataCollector(new FormDataExtractor())); } /** @@ -46,11 +44,19 @@ public function testGetExtendedType() public function testBuildForm() { - $builder = $this->createMock(FormBuilderInterface::class); - $builder->expects($this->atLeastOnce()) - ->method('addEventSubscriber') - ->with($this->isInstanceOf(DataCollectorListener::class)); - - $this->extension->buildForm($builder, []); + $eventDispatcher = new EventDispatcher(); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::PRE_SET_DATA)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::POST_SET_DATA)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::PRE_SUBMIT)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::SUBMIT)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::POST_SUBMIT)); + + $this->extension->buildForm(new FormBuilder(null, null, $eventDispatcher, new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory()))), []); + + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::PRE_SET_DATA)); + $this->assertTrue($eventDispatcher->hasListeners(FormEvents::POST_SET_DATA)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::PRE_SUBMIT)); + $this->assertFalse($eventDispatcher->hasListeners(FormEvents::SUBMIT)); + $this->assertTrue($eventDispatcher->hasListeners(FormEvents::POST_SUBMIT)); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index eb0a13c3334a..b99240c8cb30 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -17,7 +17,6 @@ use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension; use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\FormTypeGuesserInterface; class DependencyInjectionExtensionTest extends TestCase { @@ -58,7 +57,7 @@ public function testThrowExceptionForInvalidExtendedType() public function testGetTypeGuesser() { - $extension = new DependencyInjectionExtension(new ContainerBuilder(), [], [$this->createMock(FormTypeGuesserInterface::class)]); + $extension = new DependencyInjectionExtension(new ContainerBuilder(), [], [new FormTypeGuesserChain([])]); $this->assertInstanceOf(FormTypeGuesserChain::class, $extension->getTypeGuesser()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index a569a81c6e81..58b8d4e05f89 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -366,7 +366,7 @@ function () { throw new TransformationFailedException(); } public function testTransformationFailedExceptionInvalidMessageIsUsed() { - $object = $this->createMock('\stdClass'); + $object = new \stdClass(); $form = $this ->getBuilder('name', '\stdClass', [ diff --git a/src/Symfony/Component/Form/Tests/Fixtures/ArrayChoiceLoader.php b/src/Symfony/Component/Form/Tests/Fixtures/ArrayChoiceLoader.php new file mode 100644 index 000000000000..7224d0e93639 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/ArrayChoiceLoader.php @@ -0,0 +1,15 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class ConfigurableFormType extends AbstractType +{ + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefined(['a', 'b']); + } + + public function getBlockPrefix(): string + { + return 'configurable_form_prefix'; + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Map.php b/src/Symfony/Component/Form/Tests/Fixtures/Map.php new file mode 100644 index 000000000000..3faa38cd4d3e --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/Map.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +class Map implements \ArrayAccess +{ + private $data = []; + + public function offsetExists($offset): bool + { + return isset($this->data[$offset]); + } + + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->data[$offset]; + } + + public function offsetSet($offset, $value): void + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset): void + { + unset($this->data[$offset]); + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/NullFormTypeGuesser.php b/src/Symfony/Component/Form/Tests/Fixtures/NullFormTypeGuesser.php new file mode 100644 index 000000000000..81e728598083 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/NullFormTypeGuesser.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\FormTypeGuesserInterface; +use Symfony\Component\Form\Guess\TypeGuess; +use Symfony\Component\Form\Guess\ValueGuess; + +class NullFormTypeGuesser implements FormTypeGuesserInterface +{ + public function guessType($class, $property): ?TypeGuess + { + return null; + } + + public function guessRequired($class, $property): ?ValueGuess + { + return null; + } + + public function guessMaxLength($class, $property): ?ValueGuess + { + return null; + } + + public function guessPattern($class, $property): ?ValueGuess + { + return null; + } +} diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 878d52725903..d55f7733435f 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -12,35 +12,29 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\ButtonBuilder; use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactoryBuilder; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormRegistry; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\SubmitButtonBuilder; class FormBuilderTest extends TestCase { - private $dispatcher; private $factory; private $builder; protected function setUp(): void { - $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->factory = $this->createMock(FormFactoryInterface::class); - $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); - } - - protected function tearDown(): void - { - $this->dispatcher = null; - $this->factory = null; - $this->builder = null; + $this->factory = new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())); + $this->builder = new FormBuilder('name', null, new EventDispatcher(), $this->factory); } /** @@ -68,9 +62,9 @@ public function testAddTypeNoString() public function testAddWithGuessFluent() { - $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); - $builder = $this->builder->add('foo'); - $this->assertSame($builder, $this->builder); + $rootFormBuilder = new FormBuilder('name', 'stdClass', new EventDispatcher(), $this->factory); + $childFormBuilder = $rootFormBuilder->add('foo'); + $this->assertSame($childFormBuilder, $rootFormBuilder); } public function testAddIsFluent() @@ -95,11 +89,6 @@ public function testAddIntegerName() public function testAll() { - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->willReturn(new FormBuilder('foo', null, $this->dispatcher, $this->factory)); - $this->assertCount(0, $this->builder->all()); $this->assertFalse($this->builder->has('foo')); @@ -117,7 +106,7 @@ public function testAll() public function testMaintainOrderOfLazyAndExplicitChildren() { $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $this->builder->add($this->getFormBuilder('bar')); + $this->builder->add(new FormBuilder('bar', null, new EventDispatcher(), $this->factory)); $this->builder->add('baz', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $children = $this->builder->all(); @@ -149,12 +138,9 @@ public function testRemoveAndGetForm() public function testCreateNoTypeNo() { - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) - ; + $builder = $this->builder->create('foo'); - $this->builder->create('foo'); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); } public function testAddButton() @@ -175,42 +161,25 @@ public function testGetUnknown() public function testGetExplicitType() { - $expectedType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; - $expectedName = 'foo'; - $expectedOptions = ['bar' => 'baz']; - - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with($expectedName, $expectedType, null, $expectedOptions) - ->willReturn($this->getFormBuilder()); - - $this->builder->add($expectedName, $expectedType, $expectedOptions); - $builder = $this->builder->get($expectedName); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder = $this->builder->get('foo'); $this->assertNotSame($builder, $this->builder); } public function testGetGuessedType() { - $expectedName = 'foo'; - $expectedOptions = ['bar' => 'baz']; + $rootFormBuilder = new FormBuilder('name', 'stdClass', new EventDispatcher(), $this->factory); + $rootFormBuilder->add('foo'); + $fooBuilder = $rootFormBuilder->get('foo'); - $this->factory->expects($this->once()) - ->method('createBuilderForProperty') - ->with('stdClass', $expectedName, null, $expectedOptions) - ->willReturn($this->getFormBuilder()); - - $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); - $this->builder->add($expectedName, null, $expectedOptions); - $builder = $this->builder->get($expectedName); - - $this->assertNotSame($builder, $this->builder); + $this->assertNotSame($fooBuilder, $rootFormBuilder); } public function testGetFormConfigErasesReferences() { - $builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); - $builder->add(new FormBuilder('child', null, $this->dispatcher, $this->factory)); + $builder = new FormBuilder('name', null, new EventDispatcher(), $this->factory); + $builder->add(new FormBuilder('child', null, new EventDispatcher(), $this->factory)); $config = $builder->getFormConfig(); $reflClass = new \ReflectionClass($config); @@ -226,19 +195,9 @@ public function testGetFormConfigErasesReferences() public function testGetButtonBuilderBeforeExplicitlyResolvingAllChildren() { - $builder = new FormBuilder('name', null, $this->dispatcher, (new FormFactoryBuilder())->getFormFactory()); + $builder = new FormBuilder('name', null, new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory()); $builder->add('submit', SubmitType::class); $this->assertInstanceOf(ButtonBuilder::class, $builder->get('submit')); } - - private function getFormBuilder($name = 'name') - { - $mock = $this->createMock(FormBuilder::class); - $mock->expects($this->any()) - ->method('getName') - ->willReturn($name); - - return $mock; - } } diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php index d1f1b9c3edad..239ffbc99a61 100644 --- a/src/Symfony/Component/Form/Tests/FormConfigTest.php +++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\FormConfigBuilder; use Symfony\Component\Form\NativeRequestHandler; @@ -67,13 +67,11 @@ public function getHtml4Ids() */ public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $expectedException = null) { - $dispatcher = $this->createMock(EventDispatcherInterface::class); - if (null !== $expectedException) { $this->expectException($expectedException); } - $formConfigBuilder = new FormConfigBuilder($name, null, $dispatcher); + $formConfigBuilder = new FormConfigBuilder($name, null, new EventDispatcher()); $this->assertSame((string) $name, $formConfigBuilder->getName()); } @@ -135,8 +133,6 @@ public function testSetMethodAllowsPatch() private function getConfigBuilder($name = 'name') { - $dispatcher = $this->createMock(EventDispatcherInterface::class); - - return new FormConfigBuilder($name, null, $dispatcher); + return new FormConfigBuilder($name, null, new EventDispatcher()); } } diff --git a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php index b818dcd8c487..44c304558b83 100644 --- a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php +++ b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php @@ -16,7 +16,9 @@ use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormErrorIterator; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormRegistry; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Validator\ConstraintViolation; class FormErrorIteratorTest extends TestCase @@ -34,7 +36,7 @@ public function testFindByCodes($code, $violationsCount) 'form', null, new EventDispatcher(), - $this->createMock(FormFactoryInterface::class), + new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), [] ); diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 9f4825e3fcdf..fbabec1dd02c 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -14,13 +14,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactoryBuilder; -use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\Tests\Fixtures\FooType; +use Symfony\Component\Form\Tests\Fixtures\NullFormTypeGuesser; class FormFactoryBuilderTest extends TestCase { private $registry; - private $guesser; private $type; protected function setUp(): void @@ -29,7 +28,6 @@ protected function setUp(): void $this->registry = $factory->getProperty('registry'); $this->registry->setAccessible(true); - $this->guesser = $this->createMock(FormTypeGuesserInterface::class); $this->type = new FooType(); } @@ -50,7 +48,7 @@ public function testAddType() public function testAddTypeGuesser() { $factoryBuilder = new FormFactoryBuilder(); - $factoryBuilder->addTypeGuesser($this->guesser); + $factoryBuilder->addTypeGuesser(new NullFormTypeGuesser()); $factory = $factoryBuilder->getFormFactory(); $registry = $this->registry->getValue($factory); diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 2fa5e6d313e3..8f7a03d0bc33 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -11,21 +11,21 @@ namespace Symfony\Component\Form\Tests; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\Extension\Core\Type\PasswordType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormRegistryInterface; use Symfony\Component\Form\FormTypeGuesserChain; use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; use Symfony\Component\Form\Guess\ValueGuess; -use Symfony\Component\Form\ResolvedFormType; -use Symfony\Component\Form\ResolvedFormTypeInterface; -use Symfony\Component\Form\Test\FormBuilderInterface; +use Symfony\Component\Form\PreloadedExtension; +use Symfony\Component\Form\ResolvedFormTypeFactory; +use Symfony\Component\Form\Tests\Fixtures\ConfigurableFormType; /** * @author Bernhard Schussek @@ -33,25 +33,20 @@ class FormFactoryTest extends TestCase { /** - * @var MockObject&FormTypeGuesserInterface + * @var ConfigurableFormTypeGuesser */ private $guesser1; /** - * @var MockObject&FormTypeGuesserInterface + * @var ConfigurableFormTypeGuesser */ private $guesser2; /** - * @var MockObject&FormRegistryInterface + * @var FormRegistryInterface */ private $registry; - /** - * @var MockObject&FormBuilderInterface - */ - private $builder; - /** * @var FormFactory */ @@ -59,100 +54,36 @@ class FormFactoryTest extends TestCase protected function setUp(): void { - $this->guesser1 = $this->createMock(FormTypeGuesserInterface::class); - $this->guesser2 = $this->createMock(FormTypeGuesserInterface::class); - $this->registry = $this->createMock(FormRegistryInterface::class); - $this->builder = $this->createMock(FormBuilderInterface::class); + $this->guesser1 = new ConfigurableFormTypeGuesser(); + $this->guesser2 = new ConfigurableFormTypeGuesser(); + $this->registry = new FormRegistry([ + new PreloadedExtension([ + new ConfigurableFormType(), + ], [], new FormTypeGuesserChain([$this->guesser1, $this->guesser2])), + ], new ResolvedFormTypeFactory()); $this->factory = new FormFactory($this->registry); - - $this->registry->expects($this->any()) - ->method('getTypeGuesser') - ->willReturn(new FormTypeGuesserChain([ - $this->guesser1, - $this->guesser2, - ])); } public function testCreateNamedBuilderWithTypeName() { - $options = ['a' => '1', 'b' => '2']; - $resolvedOptions = ['a' => '2', 'b' => '3']; - $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->willReturn($resolvedType); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->willReturn($this->builder); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->willReturn($resolvedOptions); + $builder = $this->factory->createNamedBuilder('name', ConfigurableFormType::class, null, ['a' => '1', 'b' => '2']); - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', null, $options)); + $this->assertSame('1', $builder->getOption('a')); + $this->assertSame('2', $builder->getOption('b')); } public function testCreateNamedBuilderFillsDataOption() { - $givenOptions = ['a' => '1', 'b' => '2']; - $expectedOptions = array_merge($givenOptions, ['data' => 'DATA']); - $resolvedOptions = ['a' => '2', 'b' => '3', 'data' => 'DATA']; - $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->willReturn($resolvedType); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $expectedOptions) - ->willReturn($this->builder); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->willReturn($resolvedOptions); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', 'DATA', $givenOptions)); + $builder = $this->factory->createNamedBuilder('name', ConfigurableFormType::class, 'DATA', ['a' => '1', 'b' => '2']); + + $this->assertSame('DATA', $builder->getOption('data')); } public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() { - $options = ['a' => '1', 'b' => '2', 'data' => 'CUSTOM']; - $resolvedOptions = ['a' => '2', 'b' => '3', 'data' => 'CUSTOM']; - $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->willReturn($resolvedType); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->willReturn($this->builder); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->willReturn($resolvedOptions); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); + $builder = $this->factory->createNamedBuilder('name', ConfigurableFormType::class, 'DATA', ['a' => '1', 'b' => '2', 'data' => 'CUSTOM']); - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', 'DATA', $options)); + $this->assertSame('CUSTOM', $builder->getOption('data')); } public function testCreateNamedBuilderThrowsUnderstandableException() @@ -171,318 +102,150 @@ public function testCreateThrowsUnderstandableException() public function testCreateUsesBlockPrefixIfTypeGivenAsString() { - $options = ['a' => '1', 'b' => '2']; - $resolvedOptions = ['a' => '2', 'b' => '3']; + $form = $this->factory->create(ConfigurableFormType::class); - // the interface does not have the method, so use the real class - $resolvedType = $this->createMock(ResolvedFormType::class); - $resolvedType->expects($this->any()) - ->method('getBlockPrefix') - ->willReturn('TYPE_PREFIX'); + $this->assertSame('configurable_form_prefix', $form->getName()); + } - $this->registry->expects($this->any()) - ->method('getType') - ->with('TYPE') - ->willReturn($resolvedType); + public function testCreateNamed() + { + $form = $this->factory->createNamed('name', ConfigurableFormType::class, null, ['a' => '1', 'b' => '2']); - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'TYPE_PREFIX', $options) - ->willReturn($this->builder); + $this->assertSame('1', $form->getConfig()->getOption('a')); + $this->assertSame('2', $form->getConfig()->getOption('b')); + } - $this->builder->expects($this->any()) - ->method('getOptions') - ->willReturn($resolvedOptions); + public function testCreateBuilderForPropertyWithoutTypeGuesser() + { + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); + $this->assertSame('firstName', $builder->getName()); + } - $form = $this->createForm(); + public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() + { + $this->guesser1->configureTypeGuess(TextType::class, ['attr' => ['maxlength' => 10]], Guess::MEDIUM_CONFIDENCE); + $this->guesser2->configureTypeGuess(PasswordType::class, ['attr' => ['maxlength' => 7]], Guess::HIGH_CONFIDENCE); - $this->builder->expects($this->once()) - ->method('getForm') - ->willReturn($form); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->assertSame($form, $this->factory->create('TYPE', null, $options)); + $this->assertSame('firstName', $builder->getName()); + $this->assertSame(['maxlength' => 7], $builder->getOption('attr')); + $this->assertInstanceOf(PasswordType::class, $builder->getType()->getInnerType()); } - public function testCreateNamed() + public function testCreateBuilderCreatesTextFormIfNoGuess() { - $options = ['a' => '1', 'b' => '2']; - $resolvedOptions = ['a' => '2', 'b' => '3']; - $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->willReturn($resolvedType); + $this->assertSame('firstName', $builder->getName()); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); + } - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->willReturn($this->builder); + public function testOptionsCanBeOverridden() + { + $this->guesser1->configureTypeGuess(TextType::class, ['attr' => ['class' => 'foo', 'maxlength' => 10]], Guess::MEDIUM_CONFIDENCE); - $this->builder->expects($this->any()) - ->method('getOptions') - ->willReturn($resolvedOptions); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName', null, ['attr' => ['maxlength' => 11]]); - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); + $this->assertSame('firstName', $builder->getName()); + $this->assertSame(['class' => 'foo', 'maxlength' => 11], $builder->getOption('attr')); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); + } - $form = $this->createForm(); + public function testCreateBuilderUsesMaxLengthIfFound() + { + $this->guesser1->configureMaxLengthGuess(15, Guess::MEDIUM_CONFIDENCE); + $this->guesser2->configureMaxLengthGuess(20, Guess::HIGH_CONFIDENCE); - $this->builder->expects($this->once()) - ->method('getForm') - ->willReturn($form); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->assertSame($form, $this->factory->createNamed('name', 'type', null, $options)); + $this->assertSame('firstName', $builder->getName()); + $this->assertSame(['maxlength' => 20], $builder->getOption('attr')); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); } - public function testCreateBuilderForPropertyWithoutTypeGuesser() + public function testCreateBuilderUsesMaxLengthAndPattern() { - $registry = $this->createMock(FormRegistryInterface::class); - $factory = $this->getMockBuilder(FormFactory::class) - ->setMethods(['createNamedBuilder']) - ->setConstructorArgs([$registry]) - ->getMock(); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) - ->willReturn($this->builder); + $this->guesser1->configureMaxLengthGuess(20, Guess::HIGH_CONFIDENCE); + $this->guesser2->configurePatternGuess('.{5,}', Guess::HIGH_CONFIDENCE); - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName', null, ['attr' => ['class' => 'tinymce']]); - $this->assertSame($this->builder, $this->builder); + $this->assertSame('firstName', $builder->getName()); + $this->assertSame(['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce'], $builder->getOption('attr')); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); } - public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() + public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->willReturn(new TypeGuess( - 'Symfony\Component\Form\Extension\Core\Type\TextType', - ['attr' => ['maxlength' => 10]], - Guess::MEDIUM_CONFIDENCE - )); - - $this->guesser2->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->willReturn(new TypeGuess( - 'Symfony\Component\Form\Extension\Core\Type\PasswordType', - ['attr' => ['maxlength' => 7]], - Guess::HIGH_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - - $this->assertSame($this->builder, $this->builder); + $this->guesser1->configureRequiredGuess(true, Guess::MEDIUM_CONFIDENCE); + $this->guesser2->configureRequiredGuess(false, Guess::HIGH_CONFIDENCE); + + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); + + $this->assertSame('firstName', $builder->getName()); + $this->assertFalse($builder->getOption('required')); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); } - public function testCreateBuilderCreatesTextFormIfNoGuess() + public function testCreateBuilderUsesPatternIfFound() { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->willReturn(null); + $this->guesser1->configurePatternGuess('[a-z]', Guess::MEDIUM_CONFIDENCE); + $this->guesser2->configurePatternGuess('[a-zA-Z]', Guess::HIGH_CONFIDENCE); - $factory = $this->getMockFactory(['createNamedBuilder']); + $builder = $this->factory->createBuilderForProperty('Application\Author', 'firstName'); - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->willReturn($this->builder); + $this->assertSame('firstName', $builder->getName()); + $this->assertSame(['pattern' => '[a-zA-Z]'], $builder->getOption('attr')); + $this->assertInstanceOf(TextType::class, $builder->getType()->getInnerType()); + } +} - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); +class ConfigurableFormTypeGuesser implements FormTypeGuesserInterface +{ + private $typeGuess; + private $requiredGuess; + private $maxLengthGuess; + private $patternGuess; - $this->assertSame($this->builder, $this->builder); + public function guessType($class, $property): ?TypeGuess + { + return $this->typeGuess; } - public function testOptionsCanBeOverridden() + public function guessRequired($class, $property): ?ValueGuess { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->willReturn(new TypeGuess( - 'Symfony\Component\Form\Extension\Core\Type\TextType', - ['attr' => ['class' => 'foo', 'maxlength' => 10]], - Guess::MEDIUM_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName', - null, - ['attr' => ['maxlength' => 11]] - ); - - $this->assertSame($this->builder, $this->builder); + return $this->requiredGuess; } - public function testCreateBuilderUsesMaxLengthIfFound() + public function guessMaxLength($class, $property): ?ValueGuess { - $this->guesser1->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - 15, - Guess::MEDIUM_CONFIDENCE - )); - - $this->guesser2->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - 20, - Guess::HIGH_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertSame($this->builder, $this->builder); + return $this->maxLengthGuess; } - public function testCreateBuilderUsesMaxLengthAndPattern() + public function guessPattern($class, $property): ?ValueGuess { - $this->guesser1->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - 20, - Guess::HIGH_CONFIDENCE - )); - - $this->guesser2->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - '.{5,}', - Guess::HIGH_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName', - null, - ['attr' => ['class' => 'tinymce']] - ); - - $this->assertSame($this->builder, $this->builder); + return $this->patternGuess; } - public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() + public function configureTypeGuess(string $type, array $options, int $confidence): void { - $this->guesser1->expects($this->once()) - ->method('guessRequired') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - true, - Guess::MEDIUM_CONFIDENCE - )); - - $this->guesser2->expects($this->once()) - ->method('guessRequired') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - false, - Guess::HIGH_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertSame($this->builder, $this->builder); + $this->typeGuess = new TypeGuess($type, $options, $confidence); } - public function testCreateBuilderUsesPatternIfFound() + public function configureRequiredGuess(bool $required, int $confidence): void { - $this->guesser1->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - '[a-z]', - Guess::MEDIUM_CONFIDENCE - )); - - $this->guesser2->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->willReturn(new ValueGuess( - '[a-zA-Z]', - Guess::HIGH_CONFIDENCE - )); - - $factory = $this->getMockFactory(['createNamedBuilder']); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']]) - ->willReturn($this->builder); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertSame($this->builder, $this->builder); + $this->requiredGuess = new ValueGuess($required, $confidence); } - protected function createForm() + public function configureMaxLengthGuess(int $maxLength, int $confidence): void { - $formBuilder = new FormBuilder('', null, new EventDispatcher(), $this->factory); - - return $formBuilder->getForm(); + $this->maxLengthGuess = new ValueGuess($maxLength, $confidence); } - private function getMockFactory(array $methods = []) + public function configurePatternGuess(string $pattern, int $confidence): void { - return $this->getMockBuilder(FormFactory::class) - ->setMethods($methods) - ->setConstructorArgs([$this->registry]) - ->getMock(); + $this->patternGuess = new ValueGuess($pattern, $confidence); } } diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index cdf8ea427ba1..8cee7282a4de 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -11,23 +11,20 @@ namespace Symfony\Component\Form\Tests; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Exception\LogicException; -use Symfony\Component\Form\FormExtensionInterface; use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\FormTypeGuesserInterface; +use Symfony\Component\Form\PreloadedExtension; use Symfony\Component\Form\ResolvedFormType; use Symfony\Component\Form\ResolvedFormTypeFactory; -use Symfony\Component\Form\ResolvedFormTypeFactoryInterface; -use Symfony\Component\Form\ResolvedFormTypeInterface; use Symfony\Component\Form\Tests\Fixtures\FooSubType; use Symfony\Component\Form\Tests\Fixtures\FooType; use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension; use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension; use Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType; +use Symfony\Component\Form\Tests\Fixtures\NullFormTypeGuesser; use Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBar; use Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBaz; use Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo; @@ -43,21 +40,6 @@ class FormRegistryTest extends TestCase */ private $registry; - /** - * @var MockObject&ResolvedFormTypeFactoryInterface - */ - private $resolvedTypeFactory; - - /** - * @var MockObject&FormTypeGuesserInterface - */ - private $guesser1; - - /** - * @var MockObject&FormTypeGuesserInterface - */ - private $guesser2; - /** * @var TestExtension */ @@ -70,43 +52,34 @@ class FormRegistryTest extends TestCase protected function setUp(): void { - $this->resolvedTypeFactory = $this->createMock(ResolvedFormTypeFactory::class); - $this->guesser1 = $this->createMock(FormTypeGuesserInterface::class); - $this->guesser2 = $this->createMock(FormTypeGuesserInterface::class); - $this->extension1 = new TestExtension($this->guesser1); - $this->extension2 = new TestExtension($this->guesser2); + $this->extension1 = new TestExtension(new NullFormTypeGuesser()); + $this->extension2 = new TestExtension(new NullFormTypeGuesser()); $this->registry = new FormRegistry([ $this->extension1, $this->extension2, - ], $this->resolvedTypeFactory); + ], new ResolvedFormTypeFactory()); } public function testGetTypeFromExtension() { $type = new FooType(); - $resolvedType = new ResolvedFormType($type); - $this->extension2->addType($type); - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->willReturn($resolvedType); + $resolvedFormType = $this->registry->getType(FooType::class); - $this->assertSame($resolvedType, $this->registry->getType(\get_class($type))); + $this->assertInstanceOf(ResolvedFormType::class, $resolvedFormType); + $this->assertSame($type, $resolvedFormType->getInnerType()); } public function testLoadUnregisteredType() { $type = new FooType(); - $resolvedType = new ResolvedFormType($type); - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->willReturn($resolvedType); + $resolvedFormType = $this->registry->getType(FooType::class); - $this->assertSame($resolvedType, $this->registry->getType('Symfony\Component\Form\Tests\Fixtures\FooType')); + $this->assertInstanceOf(ResolvedFormType::class, $resolvedFormType); + $this->assertInstanceOf(FooType::class, $resolvedFormType->getInnerType()); + $this->assertNotSame($type, $resolvedFormType->getInnerType()); } public function testFailIfUnregisteredTypeNoClass() @@ -126,39 +99,35 @@ public function testGetTypeWithTypeExtensions() $type = new FooType(); $ext1 = new FooTypeBarExtension(); $ext2 = new FooTypeBazExtension(); - $resolvedType = new ResolvedFormType($type, [$ext1, $ext2]); $this->extension2->addType($type); $this->extension1->addTypeExtension($ext1); $this->extension2->addTypeExtension($ext2); - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type, [$ext1, $ext2]) - ->willReturn($resolvedType); + $resolvedFormType = $this->registry->getType(FooType::class); - $this->assertSame($resolvedType, $this->registry->getType(\get_class($type))); + $this->assertInstanceOf(ResolvedFormType::class, $resolvedFormType); + $this->assertSame($type, $resolvedFormType->getInnerType()); + $this->assertSame([$ext1, $ext2], $resolvedFormType->getTypeExtensions()); } public function testGetTypeConnectsParent() { $parentType = new FooType(); $type = new FooSubType(); - $parentResolvedType = new ResolvedFormType($parentType); - $resolvedType = new ResolvedFormType($type); $this->extension1->addType($parentType); $this->extension2->addType($type); - $this->resolvedTypeFactory->expects($this->exactly(2)) - ->method('createResolvedType') - ->withConsecutive( - [$parentType], - [$type, [], $parentResolvedType] - ) - ->willReturnOnConsecutiveCalls($parentResolvedType, $resolvedType); + $resolvedFormType = $this->registry->getType(FooSubType::class); + + $this->assertInstanceOf(ResolvedFormType::class, $resolvedFormType); + $this->assertSame($type, $resolvedFormType->getInnerType()); + + $resolvedParentFormType = $resolvedFormType->getParent(); - $this->assertSame($resolvedType, $this->registry->getType(\get_class($type))); + $this->assertInstanceOf(ResolvedFormType::class, $resolvedParentFormType); + $this->assertSame($parentType, $resolvedParentFormType->getInnerType()); } public function testFormCannotHaveItselfAsAParent() @@ -196,26 +165,14 @@ public function testGetTypeThrowsExceptionIfTypeNotFound() public function testHasTypeAfterLoadingFromExtension() { $type = new FooType(); - $resolvedType = new ResolvedFormType($type); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->willReturn($resolvedType); - $this->extension2->addType($type); - $this->assertTrue($this->registry->hasType(\get_class($type))); + $this->assertTrue($this->registry->hasType(FooType::class)); } public function testHasTypeIfFQCN() { - $this->resolvedTypeFactory - ->expects($this->any()) - ->method('createResolvedType') - ->willReturn($this->createMock(ResolvedFormTypeInterface::class)); - - $this->assertTrue($this->registry->hasType('Symfony\Component\Form\Tests\Fixtures\FooType')); + $this->assertTrue($this->registry->hasType(FooType::class)); } public function testDoesNotHaveTypeIfNonExistingClass() @@ -230,14 +187,11 @@ public function testDoesNotHaveTypeIfNoFormType() public function testGetTypeGuesser() { - $expectedGuesser = new FormTypeGuesserChain([$this->guesser1, $this->guesser2]); + $expectedGuesser = new FormTypeGuesserChain([new NullFormTypeGuesser(), new NullFormTypeGuesser()]); $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); - $registry = new FormRegistry( - [$this->createMock(FormExtensionInterface::class)], - $this->resolvedTypeFactory - ); + $registry = new FormRegistry([new PreloadedExtension([], [])], new ResolvedFormTypeFactory()); $this->assertNull($registry->getTypeGuesser()); } diff --git a/src/Symfony/Component/Form/Tests/FormRendererTest.php b/src/Symfony/Component/Form/Tests/FormRendererTest.php index 00184ae2c5d6..9858fffadf47 100644 --- a/src/Symfony/Component/Form/Tests/FormRendererTest.php +++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php @@ -12,19 +12,30 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\AbstractRendererEngine; use Symfony\Component\Form\FormRenderer; +use Symfony\Component\Form\FormView; class FormRendererTest extends TestCase { public function testHumanize() { - $renderer = $this->getMockBuilder(FormRenderer::class) - ->setMethods(null) - ->disableOriginalConstructor() - ->getMock() - ; + $renderer = new FormRenderer(new DummyFormRendererEngine()); $this->assertEquals('Is active', $renderer->humanize('is_active')); $this->assertEquals('Is active', $renderer->humanize('isActive')); } } + +class DummyFormRendererEngine extends AbstractRendererEngine +{ + public function renderBlock(FormView $view, $resource, $blockName, array $variables = []): string + { + return ''; + } + + protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName): bool + { + return true; + } +} diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 931b98d14402..c841f505ac0a 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -11,19 +11,23 @@ namespace Symfony\Component\Form\Tests; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormConfigInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormTypeExtensionInterface; use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\ResolvedFormType; -use Symfony\Component\Form\Test\FormBuilderInterface; +use Symfony\Component\Form\ResolvedFormTypeFactory; +use Symfony\Component\Form\Tests\Fixtures\ConfigurableFormType; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -32,23 +36,25 @@ */ class ResolvedFormTypeTest extends TestCase { + private $calls; + /** - * @var MockObject&FormTypeInterface + * @var FormTypeInterface */ private $parentType; /** - * @var MockObject&FormTypeInterface + * @var FormTypeInterface */ private $type; /** - * @var MockObject&FormTypeExtensionInterface + * @var FormTypeExtensionInterface */ private $extension1; /** - * @var MockObject&FormTypeExtensionInterface + * @var FormTypeExtensionInterface */ private $extension2; @@ -62,51 +68,27 @@ class ResolvedFormTypeTest extends TestCase */ private $resolvedType; + /** + * @var FormFactoryInterface + */ + private $formFactory; + protected function setUp(): void { - $this->parentType = $this->getMockFormType(); - $this->type = $this->getMockFormType(); - $this->extension1 = $this->getMockFormTypeExtension(); - $this->extension2 = $this->getMockFormTypeExtension(); + $this->calls = []; + $this->parentType = new UsageTrackingParentFormType($this->calls); + $this->type = new UsageTrackingFormType($this->calls); + $this->extension1 = new UsageTrackingFormTypeExtension($this->calls, ['c' => 'c_default']); + $this->extension2 = new UsageTrackingFormTypeExtension($this->calls, ['d' => 'd_default']); $this->parentResolvedType = new ResolvedFormType($this->parentType); $this->resolvedType = new ResolvedFormType($this->type, [$this->extension1, $this->extension2], $this->parentResolvedType); + $this->formFactory = new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())); } public function testGetOptionsResolver() { - $i = 0; - - $assertIndexAndAddOption = function ($index, $option, $default) use (&$i) { - return function (OptionsResolver $resolver) use (&$i, $index, $option, $default) { - $this->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - - $resolver->setDefaults([$option => $default]); - }; - }; - - // First the default options are generated for the super type - $this->parentType->expects($this->once()) - ->method('configureOptions') - ->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default')); - - // The form type itself - $this->type->expects($this->once()) - ->method('configureOptions') - ->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default')); - - // And its extensions - $this->extension1->expects($this->once()) - ->method('configureOptions') - ->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default')); - - $this->extension2->expects($this->once()) - ->method('configureOptions') - ->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default')); - - $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; - $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; + $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom', 'foo' => 'bar']; + $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default', 'foo' => 'bar']; $resolver = $this->resolvedType->getOptionsResolver(); @@ -115,26 +97,10 @@ public function testGetOptionsResolver() public function testCreateBuilder() { - $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; - $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; - $optionsResolver = $this->createMock(OptionsResolver::class); + $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom', 'foo' => 'bar']; + $resolvedOptions = ['b' => 'b_default', 'd' => 'd_default', 'a' => 'a_custom', 'c' => 'c_custom', 'foo' => 'bar']; - $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class) - ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) - ->setMethods(['getOptionsResolver']) - ->getMock(); - - $this->resolvedType->expects($this->once()) - ->method('getOptionsResolver') - ->willReturn($optionsResolver); - - $optionsResolver->expects($this->once()) - ->method('resolve') - ->with($givenOptions) - ->willReturn($resolvedOptions); - - $factory = $this->getMockFormFactory(); - $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); + $builder = $this->resolvedType->createBuilder($this->formFactory, 'name', $givenOptions); $this->assertSame($this->resolvedType, $builder->getType()); $this->assertSame($resolvedOptions, $builder->getOptions()); @@ -143,26 +109,19 @@ public function testCreateBuilder() public function testCreateBuilderWithDataClassOption() { - $givenOptions = ['data_class' => 'Foo']; - $resolvedOptions = ['data_class' => \stdClass::class]; - $optionsResolver = $this->createMock(OptionsResolver::class); - - $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class) - ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) - ->setMethods(['getOptionsResolver']) - ->getMock(); - - $this->resolvedType->expects($this->once()) - ->method('getOptionsResolver') - ->willReturn($optionsResolver); - - $optionsResolver->expects($this->once()) - ->method('resolve') - ->with($givenOptions) - ->willReturn($resolvedOptions); + $resolvedOptions = [ + 'a' => 'a_default', + 'b' => 'b_default', + 'c' => 'c_default', + 'd' => 'd_default', + 'data_class' => \stdClass::class, + 'foo' => 'bar', + ]; - $factory = $this->getMockFormFactory(); - $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); + $builder = $this->resolvedType->createBuilder($this->formFactory, 'name', [ + 'data_class' => \stdClass::class, + 'foo' => 'bar', + ]); $this->assertSame($this->resolvedType, $builder->getType()); $this->assertSame($resolvedOptions, $builder->getOptions()); @@ -172,74 +131,21 @@ public function testCreateBuilderWithDataClassOption() public function testFailsCreateBuilderOnInvalidFormOptionsResolution() { $this->expectException(MissingOptionsException::class); - $this->expectExceptionMessage('An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\HiddenType": The required option "foo" is missing.'); - $optionsResolver = (new OptionsResolver()) - ->setRequired('foo') - ; - $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class) - ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) - ->setMethods(['getOptionsResolver', 'getInnerType']) - ->getMock() - ; - $this->resolvedType->expects($this->once()) - ->method('getOptionsResolver') - ->willReturn($optionsResolver) - ; - $this->resolvedType->expects($this->once()) - ->method('getInnerType') - ->willReturn(new HiddenType()) - ; - $factory = $this->getMockFormFactory(); - - $this->resolvedType->createBuilder($factory, 'name'); + $this->expectExceptionMessage(sprintf('An error has occurred resolving the options of the form "%s": The required option "foo" is missing.', UsageTrackingFormType::class)); + + $this->resolvedType->createBuilder($this->formFactory, 'name'); } public function testBuildForm() { - $i = 0; - - $assertIndex = function ($index) use (&$i) { - return function () use (&$i, $index) { - $this->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - $options = ['a' => 'Foo', 'b' => 'Bar']; - $builder = $this->createMock(FormBuilderInterface::class); - - // First the form is built for the super type - $this->parentType->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->willReturnCallback($assertIndex(0)); - - // Then the type itself - $this->type->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->willReturnCallback($assertIndex(1)); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->willReturnCallback($assertIndex(2)); - - $this->extension2->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->willReturnCallback($assertIndex(3)); - - $this->resolvedType->buildForm($builder, $options); + $this->resolvedType->buildForm(new FormBuilder(null, null, new EventDispatcher(), $this->formFactory), []); + + $this->assertSame([$this->parentType, $this->type, $this->extension1, $this->extension2], $this->calls['buildForm']); } public function testCreateView() { - $form = $this->bootstrapForm(); - - $view = $this->resolvedType->createView($form); + $view = $this->resolvedType->createView($this->formFactory->create()); $this->assertInstanceOf(FormView::class, $view); $this->assertNull($view->parent); @@ -247,10 +153,9 @@ public function testCreateView() public function testCreateViewWithParent() { - $form = $this->bootstrapForm(); - $parentView = $this->createMock(FormView::class); + $parentView = new FormView(); - $view = $this->resolvedType->createView($form, $parentView); + $view = $this->resolvedType->createView($this->formFactory->create(), $parentView); $this->assertInstanceOf(FormView::class, $view); $this->assertSame($parentView, $view->parent); @@ -258,97 +163,23 @@ public function testCreateViewWithParent() public function testBuildView() { - $options = ['a' => '1', 'b' => '2']; - $form = $this->bootstrapForm(); - $view = $this->createMock(FormView::class); - - $i = 0; - - $assertIndex = function ($index) use (&$i) { - return function () use (&$i, $index) { - $this->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - // First the super type - $this->parentType->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(0)); - - // Then the type itself - $this->type->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(1)); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(2)); - - $this->extension2->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(3)); - - $this->resolvedType->buildView($view, $form, $options); + $this->resolvedType->buildView(new FormView(), $this->formFactory->create(), []); + + $this->assertSame([$this->parentType, $this->type, $this->extension1, $this->extension2], $this->calls['buildView']); } public function testFinishView() { - $options = ['a' => '1', 'b' => '2']; - $form = $this->bootstrapForm(); - $view = $this->createMock(FormView::class); - - $i = 0; - - $assertIndex = function ($index) use (&$i) { - return function () use (&$i, $index) { - $this->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - // First the super type - $this->parentType->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(0)); - - // Then the type itself - $this->type->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(1)); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(2)); - - $this->extension2->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->willReturnCallback($assertIndex(3)); - - $this->resolvedType->finishView($view, $form, $options); + $this->resolvedType->finishView(new FormView(), $this->formFactory->create(), []); + + $this->assertSame([$this->parentType, $this->type, $this->extension1, $this->extension2], $this->calls['finishView']); } public function testGetBlockPrefix() { - $this->type->expects($this->once()) - ->method('getBlockPrefix') - ->willReturn('my_prefix'); + $resolvedType = new ResolvedFormType(new ConfigurableFormType()); - $resolvedType = new ResolvedFormType($this->type); - - $this->assertSame('my_prefix', $resolvedType->getBlockPrefix()); + $this->assertSame('configurable_form_prefix', $resolvedType->getBlockPrefix()); } /** @@ -372,37 +203,84 @@ public function provideTypeClassBlockPrefixTuples() [Fixtures\FBooType::class, 'f_boo'], ]; } +} - /** - * @return MockObject&FormTypeInterface - */ - private function getMockFormType($typeClass = AbstractType::class): FormTypeInterface +class UsageTrackingFormType extends AbstractType +{ + use UsageTrackingTrait; + + public function __construct(array &$calls) { - return $this->getMockBuilder($typeClass)->setMethods(['getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); + $this->calls = &$calls; } - /** - * @return MockObject&FormTypeExtensionInterface - */ - private function getMockFormTypeExtension(): FormTypeExtensionInterface + public function getParent(): string { - return $this->getMockBuilder(AbstractTypeExtension::class)->setMethods(['getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); + return UsageTrackingParentFormType::class; } - /** - * @return MockObject&FormFactoryInterface - */ - private function getMockFormFactory(): FormFactoryInterface + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefault('b', 'b_default'); + $resolver->setDefined('data_class'); + $resolver->setRequired('foo'); + } +} + +class UsageTrackingParentFormType extends AbstractType +{ + use UsageTrackingTrait; + + public function __construct(array &$calls) + { + $this->calls = &$calls; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefault('a', 'a_default'); + } +} + +class UsageTrackingFormTypeExtension extends AbstractTypeExtension +{ + use UsageTrackingTrait; + + private $defaultOptions; + + public function __construct(array &$calls, array $defaultOptions) + { + $this->calls = &$calls; + $this->defaultOptions = $defaultOptions; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults($this->defaultOptions); + } + + public static function getExtendedTypes(): iterable { - return $this->createMock(FormFactoryInterface::class); + yield FormType::class; + } +} + +trait UsageTrackingTrait +{ + private $calls; + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $this->calls['buildForm'][] = $this; } - private function bootstrapForm(): Form + public function buildView(FormView $view, FormInterface $form, array $options): void { - $config = $this->createMock(FormConfigInterface::class); - $config->method('getInheritData')->willReturn(false); - $config->method('getName')->willReturn(''); + $this->calls['buildView'][] = $this; + } - return new Form($config); + public function finishView(FormView $view, FormInterface $form, array $options): void + { + $this->calls['finishView'][] = $this; } } diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 8edfe15634f8..f1f6ce80a585 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -11,22 +11,29 @@ namespace Symfony\Component\Form\Tests; +use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\Exception\AlreadySubmittedException; use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; use Symfony\Component\Form\Form; +use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormConfigBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; +use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormView; use Symfony\Component\Form\RequestHandlerInterface; +use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\ResolvedFormTypeInterface; use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; use Symfony\Component\Form\Tests\Fixtures\FixedFilterListener; +use Symfony\Component\Form\Tests\Fixtures\Map; use Symfony\Component\PropertyAccess\PropertyPath; class SimpleFormTest_Countable implements \Countable @@ -59,14 +66,21 @@ public function getIterator(): \Traversable } } -class SimpleFormTest extends AbstractFormTest +class SimpleFormTest extends TestCase { + private $form; + + protected function setUp(): void + { + $this->form = $this->createForm(); + } + /** * @dataProvider provideFormNames */ public function testGetPropertyPath($name, $propertyPath) { - $config = new FormConfigBuilder($name, null, $this->dispatcher); + $config = new FormConfigBuilder($name, null, new EventDispatcher()); $form = new Form($config); $this->assertEquals($propertyPath, $form->getPropertyPath()); @@ -90,7 +104,7 @@ public function testDataIsInitializedToConfiguredValue() 'foo' => 'bar', ]); - $config = new FormConfigBuilder('name', null, $this->dispatcher); + $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config->addViewTransformer($view); $config->addModelTransformer($model); $config->setData('default'); @@ -112,7 +126,7 @@ public function testDataTransformationFailure() 'foo' => 'bar', ]); - $config = new FormConfigBuilder('name', null, $this->dispatcher); + $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config->addViewTransformer($view); $config->addModelTransformer($model); $config->setData('arg'); @@ -127,53 +141,41 @@ public function testDataIsInitializedFromSubmit() $preSetData = false; $preSubmit = false; - $mock = $this->getMockBuilder(\stdClass::class) - ->setMethods(['preSetData', 'preSubmit']) - ->getMock(); - $mock->expects($this->once()) - ->method('preSetData') - ->with($this->callback(function () use (&$preSetData, $preSubmit) { - $preSetData = true; - - return false === $preSubmit; - })); - $mock->expects($this->once()) - ->method('preSubmit') - ->with($this->callback(function () use ($preSetData, &$preSubmit) { - $preSubmit = true; - - return false === $preSetData; - })); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SET_DATA, [$mock, 'preSetData']); - $config->addEventListener(FormEvents::PRE_SUBMIT, [$mock, 'preSubmit']); + $preSetDataListener = static function () use (&$preSetData, &$preSubmit): void { + $preSetData = !$preSubmit; + }; + $preSubmitListener = static function () use (&$preSetData, &$preSubmit): void { + $preSubmit = $preSetData; + }; + + $config = new FormConfigBuilder('name', null, new EventDispatcher()); + $config->addEventListener(FormEvents::PRE_SET_DATA, $preSetDataListener); + $config->addEventListener(FormEvents::PRE_SUBMIT, $preSubmitListener); $form = new Form($config); // no call to setData() or similar where the object would be // initialized otherwise $form->submit('foobar'); + + $this->assertTrue($preSetData); + $this->assertTrue($preSubmit); } // https://github.com/symfony/symfony/pull/7789 public function testFalseIsConvertedToNull() { - $mock = $this->getMockBuilder(\stdClass::class) - ->setMethods(['preSubmit']) - ->getMock(); - $mock->expects($this->once()) - ->method('preSubmit') - ->with($this->callback(function ($event) { - return null === $event->getData(); - })); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SUBMIT, [$mock, 'preSubmit']); + $passedDataIsNull = false; + + $config = new FormConfigBuilder('name', null, new EventDispatcher()); + $config->addEventListener(FormEvents::PRE_SUBMIT, static function (FormEvent $event) use (&$passedDataIsNull): void { + $passedDataIsNull = $event->getData() === null; + }); $form = new Form($config); $form->submit(false); + $this->assertTrue($passedDataIsNull); $this->assertTrue($form->isValid()); $this->assertNull($form->getData()); } @@ -278,7 +280,7 @@ public function testEmptyIfEmptyArray() public function testEmptyIfEmptyCountable() { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); + $this->form = new Form(new FormConfigBuilder('name', SimpleFormTest_Countable::class, new EventDispatcher())); $this->form->setData(new SimpleFormTest_Countable(0)); @@ -287,7 +289,7 @@ public function testEmptyIfEmptyCountable() public function testNotEmptyIfFilledCountable() { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); + $this->form = new Form(new FormConfigBuilder('name', SimpleFormTest_Countable::class, new EventDispatcher())); $this->form->setData(new SimpleFormTest_Countable(1)); @@ -296,7 +298,7 @@ public function testNotEmptyIfFilledCountable() public function testEmptyIfEmptyTraversable() { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); + $this->form = new Form(new FormConfigBuilder('name', SimpleFormTest_Traversable::class, new EventDispatcher())); $this->form->setData(new SimpleFormTest_Traversable(0)); @@ -305,7 +307,7 @@ public function testEmptyIfEmptyTraversable() public function testNotEmptyIfFilledTraversable() { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); + $this->form = new Form(new FormConfigBuilder('name', SimpleFormTest_Traversable::class, new EventDispatcher())); $this->form->setData(new SimpleFormTest_Traversable(1)); @@ -400,7 +402,7 @@ public function testSetDataThrowsExceptionIfAlreadySubmitted() public function testSetDataClonesObjectIfNotByReference() { $data = new \stdClass(); - $form = $this->getBuilder('name', null, \stdClass::class)->setByReference(false)->getForm(); + $form = $this->getBuilder('name', \stdClass::class)->setByReference(false)->getForm(); $form->setData($data); $this->assertNotSame($data, $form->getData()); @@ -410,7 +412,7 @@ public function testSetDataClonesObjectIfNotByReference() public function testSetDataDoesNotCloneObjectIfByReference() { $data = new \stdClass(); - $form = $this->getBuilder('name', null, \stdClass::class)->setByReference(true)->getForm(); + $form = $this->getBuilder('name', \stdClass::class)->setByReference(true)->getForm(); $form->setData($data); $this->assertSame($data, $form->getData()); @@ -419,7 +421,7 @@ public function testSetDataDoesNotCloneObjectIfByReference() public function testSetDataExecutesTransformationChain() { // use real event dispatcher now - $form = $this->getBuilder('name', new EventDispatcher()) + $form = $this->getBuilder('name') ->addEventSubscriber(new FixedFilterListener([ 'preSetData' => [ 'app' => 'filtered', @@ -542,7 +544,7 @@ public function testSetDataIsIgnoredIfDataIsLocked() public function testPreSetDataChangesDataIfDataIsLocked() { - $config = new FormConfigBuilder('name', null, $this->dispatcher); + $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config ->setData('default') ->setDataLocked(true) @@ -570,7 +572,7 @@ public function testSubmitConvertsEmptyToNullIfNoTransformer() public function testSubmitExecutesTransformationChain() { // use real event dispatcher now - $form = $this->getBuilder('name', new EventDispatcher()) + $form = $this->getBuilder('name') ->addEventSubscriber(new FixedFilterListener([ 'preSubmit' => [ 'client' => 'filteredclient', @@ -649,13 +651,8 @@ public function testSynchronizedAfterSubmission() public function testNotSynchronizedIfViewReverseTransformationFailed() { - $transformer = $this->getDataTransformer(); - $transformer->expects($this->once()) - ->method('reverseTransform') - ->willThrowException(new TransformationFailedException()); - $form = $this->getBuilder() - ->addViewTransformer($transformer) + ->addViewTransformer(new FixedDataTransformer(['' => ''])) ->getForm(); $form->submit('foobar'); @@ -665,13 +662,8 @@ public function testNotSynchronizedIfViewReverseTransformationFailed() public function testNotSynchronizedIfModelReverseTransformationFailed() { - $transformer = $this->getDataTransformer(); - $transformer->expects($this->once()) - ->method('reverseTransform') - ->willThrowException(new TransformationFailedException()); - $form = $this->getBuilder() - ->addModelTransformer($transformer) + ->addModelTransformer(new FixedDataTransformer(['' => ''])) ->getForm(); $form->submit('foobar'); @@ -728,7 +720,7 @@ public function testSubmitResetsErrors() public function testCreateView() { $type = $this->createMock(ResolvedFormTypeInterface::class); - $view = $this->createMock(FormView::class); + $view = new FormView(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -742,10 +734,10 @@ public function testCreateView() public function testCreateViewWithParent() { $type = $this->createMock(ResolvedFormTypeInterface::class); - $view = $this->createMock(FormView::class); + $view = new FormView(); $parentType = $this->createMock(ResolvedFormTypeInterface::class); $parentForm = $this->getBuilder()->setType($parentType)->getForm(); - $parentView = $this->createMock(FormView::class); + $parentView = new FormView(); $form = $this->getBuilder()->setType($type)->getForm(); $form->setParent($parentForm); @@ -764,8 +756,8 @@ public function testCreateViewWithParent() public function testCreateViewWithExplicitParent() { $type = $this->createMock(ResolvedFormTypeInterface::class); - $view = $this->createMock(FormView::class); - $parentView = $this->createMock(FormView::class); + $view = new FormView(); + $parentView = new FormView(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -797,7 +789,7 @@ public function testFormCannotHaveEmptyNameNotInRootLevel() $this->expectExceptionMessage('A form with an empty name cannot have a parent form.'); $this->getBuilder() ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->add($this->getBuilder('')) ->getForm(); } @@ -812,9 +804,9 @@ public function testGetPropertyPathReturnsConfiguredPath() // see https://github.com/symfony/symfony/issues/3903 public function testGetPropertyPathDefaultsToNameIfParentHasDataClass() { - $parent = $this->getBuilder(null, null, 'stdClass') + $parent = $this->getBuilder(null, \stdClass::class) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $form = $this->getBuilder('name')->getForm(); $parent->add($form); @@ -827,7 +819,7 @@ public function testGetPropertyPathDefaultsToIndexedNameIfParentDataClassIsNull( { $parent = $this->getBuilder() ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $form = $this->getBuilder('name')->getForm(); $parent->add($form); @@ -837,13 +829,13 @@ public function testGetPropertyPathDefaultsToIndexedNameIfParentDataClassIsNull( public function testGetPropertyPathDefaultsToNameIfFirstParentWithoutInheritDataHasDataClass() { - $grandParent = $this->getBuilder(null, null, 'stdClass') + $grandParent = $this->getBuilder(null, \stdClass::class) ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $parent = $this->getBuilder() ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setInheritData(true) ->getForm(); $form = $this->getBuilder('name')->getForm(); @@ -857,11 +849,11 @@ public function testGetPropertyPathDefaultsToIndexedNameIfDataClassOfFirstParent { $grandParent = $this->getBuilder() ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); $parent = $this->getBuilder() ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->setInheritData(true) ->getForm(); $form = $this->getBuilder('name')->getForm(); @@ -874,7 +866,7 @@ public function testGetPropertyPathDefaultsToIndexedNameIfDataClassOfFirstParent public function testViewDataMayBeObjectIfDataClassIsNull() { $object = new \stdClass(); - $config = new FormConfigBuilder('name', null, $this->dispatcher); + $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config->addViewTransformer(new FixedDataTransformer([ '' => '', 'foo' => $object, @@ -888,8 +880,8 @@ public function testViewDataMayBeObjectIfDataClassIsNull() public function testViewDataMayBeArrayAccessIfDataClassIsNull() { - $arrayAccess = $this->createMock(\ArrayAccess::class); - $config = new FormConfigBuilder('name', null, $this->dispatcher); + $arrayAccess = new Map(); + $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config->addViewTransformer(new FixedDataTransformer([ '' => '', 'foo' => $arrayAccess, @@ -904,7 +896,7 @@ public function testViewDataMayBeArrayAccessIfDataClassIsNull() public function testViewDataMustBeObjectIfDataClassIsSet() { $this->expectException(LogicException::class); - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); + $config = new FormConfigBuilder('name', 'stdClass', new EventDispatcher()); $config->addViewTransformer(new FixedDataTransformer([ '' => '', 'foo' => ['bar' => 'baz'], @@ -919,7 +911,7 @@ public function testSetDataCannotInvokeItself() $this->expectException(RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.'); // Cycle detection to prevent endless loops - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); + $config = new FormConfigBuilder('name', 'stdClass', new EventDispatcher()); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $event->getForm()->setData('bar'); }); @@ -932,14 +924,14 @@ public function testSubmittingWrongDataIsIgnored() { $called = 0; - $child = $this->getBuilder('child', $this->dispatcher); + $child = $this->getBuilder('child'); $child->addEventListener(FormEvents::PRE_SUBMIT, function () use (&$called) { ++$called; }); - $parent = $this->getBuilder('parent', new EventDispatcher()) + $parent = $this->getBuilder('parent') ->setCompound(true) - ->setDataMapper($this->getDataMapper()) + ->setDataMapper(new PropertyPathMapper()) ->add($child) ->getForm(); @@ -965,25 +957,27 @@ public function testHandleRequestForwardsToRequestHandler() public function testFormInheritsParentData() { - $child = $this->getBuilder('child') - ->setInheritData(true); + $nameForm = $this->getBuilder() + ->setCompound(true) + ->setDataMapper(new PropertyPathMapper()) + ->setInheritData(true) + ->getForm(); + $nameForm->add($firstNameForm = $this->getBuilder('firstName')->getForm()); + $nameForm->add($lastNameForm = $this->getBuilder('lastName')->getForm()); - $parent = $this->getBuilder('parent') + $rootForm = $this->getBuilder('') ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setData('foo') - ->addModelTransformer(new FixedDataTransformer([ - 'foo' => 'norm[foo]', - ])) - ->addViewTransformer(new FixedDataTransformer([ - 'norm[foo]' => 'view[foo]', - ])) - ->add($child) + ->setDataMapper(new PropertyPathMapper()) ->getForm(); + $rootForm->add($nameForm); + $rootForm->setData(['firstName' => 'Christian', 'lastName' => 'Flothmann']); - $this->assertSame('foo', $parent->get('child')->getData()); - $this->assertSame('norm[foo]', $parent->get('child')->getNormData()); - $this->assertSame('view[foo]', $parent->get('child')->getViewData()); + $this->assertSame('Christian', $firstNameForm->getData()); + $this->assertSame('Christian', $firstNameForm->getNormData()); + $this->assertSame('Christian', $firstNameForm->getViewData()); + $this->assertSame('Flothmann', $lastNameForm->getData()); + $this->assertSame('Flothmann', $lastNameForm->getNormData()); + $this->assertSame('Flothmann', $lastNameForm->getViewData()); } public function testInheritDataDisallowsSetData() @@ -1056,14 +1050,12 @@ public function testSubmitIsNeverFiredIfInheritData() public function testInitializeSetsDefaultData() { $config = $this->getBuilder()->setData('DEFAULT')->getFormConfig(); - $form = $this->getMockBuilder(Form::class)->setMethods(['setData'])->setConstructorArgs([$config])->getMock(); - - $form->expects($this->once()) - ->method('setData') - ->with($this->identicalTo('DEFAULT')); + $form = new Form($config); /* @var Form $form */ $form->initialize(); + + $this->assertSame('DEFAULT', $form->getData()); } public function testInitializeFailsIfParent() @@ -1081,7 +1073,7 @@ public function testCannotCallGetDataInPreSetDataListenerIfDataHasNotAlreadyBeen { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getData() if the form data has not already been set. You should call getData() on the FormEvent object instead.'); - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); + $config = new FormConfigBuilder('name', 'stdClass', new EventDispatcher()); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $event->getForm()->getData(); }); @@ -1094,7 +1086,7 @@ public function testCannotCallGetNormDataInPreSetDataListener() { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getNormData() if the form data has not already been set.'); - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); + $config = new FormConfigBuilder('name', 'stdClass', new EventDispatcher()); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $event->getForm()->getNormData(); }); @@ -1107,7 +1099,7 @@ public function testCannotCallGetViewDataInPreSetDataListener() { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getViewData() if the form data has not already been set.'); - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); + $config = new FormConfigBuilder('name', 'stdClass', new EventDispatcher()); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $event->getForm()->getViewData(); }); @@ -1116,8 +1108,13 @@ public function testCannotCallGetViewDataInPreSetDataListener() $form->setData('foo'); } - protected function createForm(): FormInterface + private function createForm(): FormInterface { return $this->getBuilder()->getForm(); } + + private function getBuilder(?string $name = 'name', string $dataClass = null, array $options = []): FormBuilder + { + return new FormBuilder($name, $dataClass, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), $options); + } } From 49ec9afc7c9a9d249fe82a65c941c396f6eea6bb Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 17 Apr 2022 13:27:19 +0200 Subject: [PATCH 18/60] fix merge --- src/Symfony/Component/Form/Tests/Fixtures/Map.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Map.php b/src/Symfony/Component/Form/Tests/Fixtures/Map.php index 3faa38cd4d3e..93409aceee23 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Map.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/Map.php @@ -20,6 +20,9 @@ public function offsetExists($offset): bool return isset($this->data[$offset]); } + /** + * @return mixed + */ #[\ReturnTypeWillChange] public function offsetGet($offset) { From 9e0cb9d6319b5564e72aed2b3d5dd9966fda3ee1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 17 Apr 2022 13:38:16 +0200 Subject: [PATCH 19/60] fix merge --- src/Symfony/Component/Form/Tests/Fixtures/Map.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Map.php b/src/Symfony/Component/Form/Tests/Fixtures/Map.php index 93409aceee23..d3a9de6f92f2 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Map.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/Map.php @@ -20,11 +20,7 @@ public function offsetExists($offset): bool return isset($this->data[$offset]); } - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->data[$offset]; } From 488a262ad5b01d6229208e7d75b2f9466db13662 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 17 Apr 2022 13:40:09 +0200 Subject: [PATCH 20/60] do not use mocks in tests when not necessary --- .../Factory/Cache/ChoiceLoaderTest.php | 8 +- .../Factory/CachingFactoryDecoratorTest.php | 330 ++++++------------ .../Factory/DefaultChoiceListFactoryTest.php | 6 +- .../Factory/PropertyAccessDecoratorTest.php | 73 ++-- .../FilterChoiceLoaderDecoratorTest.php | 42 +-- .../ViolationMapper/ViolationMapperTest.php | 38 +- .../Fixtures/DummyFormRendererEngine.php | 28 ++ .../Form/Tests/Fixtures/FixedTranslator.php | 34 ++ .../Component/Form/Tests/FormRendererTest.php | 19 +- 9 files changed, 218 insertions(+), 360 deletions(-) create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/DummyFormRendererEngine.php create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/FixedTranslator.php diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/Cache/ChoiceLoaderTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/Cache/ChoiceLoaderTest.php index a96c83866379..b2d0d2e6d700 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/Cache/ChoiceLoaderTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/Cache/ChoiceLoaderTest.php @@ -15,8 +15,8 @@ use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Factory\Cache\ChoiceLoader; use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; -use Symfony\Component\Form\FormTypeInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; class ChoiceLoaderTest extends TestCase { @@ -25,12 +25,12 @@ public function testSameFormTypeUseCachedLoader() $choices = ['f' => 'foo', 'b' => 'bar', 'z' => 'baz']; $choiceList = new ArrayChoiceList($choices); - $type = $this->createMock(FormTypeInterface::class); + $type = new FormType(); $decorated = new CallbackChoiceLoader(static function () use ($choices) { return $choices; }); $loader1 = new ChoiceLoader($type, $decorated); - $loader2 = new ChoiceLoader($type, $this->createMock(ChoiceLoaderInterface::class)); + $loader2 = new ChoiceLoader($type, new ArrayChoiceLoader()); $this->assertEquals($choiceList, $loader1->loadChoiceList()); $this->assertEquals($choiceList, $loader2->loadChoiceList()); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index a74756c8e1ed..4f5c4eb0e342 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -11,18 +11,16 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceList; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; +use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; +use Symfony\Component\Form\ChoiceList\Loader\FilterChoiceLoaderDecorator; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; -use Symfony\Component\Form\FormTypeInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; /** @@ -30,11 +28,6 @@ */ class CachingFactoryDecoratorTest extends TestCase { - /** - * @var MockObject&ChoiceListFactoryInterface - */ - private $decoratedFactory; - /** * @var CachingFactoryDecorator */ @@ -42,7 +35,6 @@ class CachingFactoryDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->createMock(ChoiceListFactoryInterface::class); $this->factory = new CachingFactoryDecorator(new DefaultChoiceListFactory()); } @@ -123,20 +115,16 @@ public function testCreateFromChoicesSameValueClosure() public function testCreateFromChoicesSameValueClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $choices = [1]; - $list = new ArrayChoiceList([]); - $formType = $this->createMock(FormTypeInterface::class); + $formType = new FormType(); $valueCallback = function () {}; - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $valueCallback) - ->willReturn($list) - ; + $list1 = $this->factory->createListFromChoices($choices, ChoiceList::value($formType, $valueCallback)); + $list2 = $this->factory->createListFromChoices($choices, ChoiceList::value($formType, function () {})); - $this->assertSame($list, $factory->createListFromChoices($choices, ChoiceList::value($formType, $valueCallback))); - $this->assertSame($list, $factory->createListFromChoices($choices, ChoiceList::value($formType, function () {}))); + $this->assertSame($list1, $list2); + $this->assertEquals(new ArrayChoiceList($choices, $valueCallback), $list1); + $this->assertEquals(new ArrayChoiceList($choices, function () {}), $list2); } public function testCreateFromChoicesDifferentValueClosure() @@ -154,58 +142,49 @@ public function testCreateFromChoicesDifferentValueClosure() public function testCreateFromChoicesSameFilterClosure() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $choices = [1]; - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); $filter = function () {}; + $list1 = $this->factory->createListFromChoices($choices, null, $filter); + $list2 = $this->factory->createListFromChoices($choices, null, $filter); + $lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static function () use ($choices) { + return $choices; + }), $filter), null); - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromChoices') - ->with($choices, null, $filter) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $factory->createListFromChoices($choices, null, $filter)); - $this->assertSame($list2, $factory->createListFromChoices($choices, null, $filter)); + $this->assertNotSame($list1, $list2); + $this->assertEquals($lazyChoiceList, $list1); + $this->assertEquals($lazyChoiceList, $list2); } public function testCreateFromChoicesSameFilterClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $choices = [1]; - $list = new ArrayChoiceList([]); - $formType = $this->createMock(FormTypeInterface::class); + $formType = new FormType(); $filterCallback = function () {}; + $list1 = $this->factory->createListFromChoices($choices, null, ChoiceList::filter($formType, $filterCallback)); + $list2 = $this->factory->createListFromChoices($choices, null, ChoiceList::filter($formType, function () {})); + $lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static function () use ($choices) { + return $choices; + }), function () {}), null); - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, null, $filterCallback) - ->willReturn($list) - ; - - $this->assertSame($list, $factory->createListFromChoices($choices, null, ChoiceList::filter($formType, $filterCallback))); - $this->assertSame($list, $factory->createListFromChoices($choices, null, ChoiceList::filter($formType, function () {}))); + $this->assertSame($list1, $list2); + $this->assertEquals($lazyChoiceList, $list1); + $this->assertEquals($lazyChoiceList, $list2); } public function testCreateFromChoicesDifferentFilterClosure() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $choices = [1]; - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); $closure1 = function () {}; $closure2 = function () {}; + $list1 = $this->factory->createListFromChoices($choices, null, $closure1); + $list2 = $this->factory->createListFromChoices($choices, null, $closure2); + $lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static function () use ($choices) { + return $choices; + }), function () {}), null); - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromChoices') - ->withConsecutive( - [$choices, null, $closure1], - [$choices, null, $closure2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $factory->createListFromChoices($choices, null, $closure1)); - $this->assertSame($list2, $factory->createListFromChoices($choices, null, $closure2)); + $this->assertNotSame($list1, $list2); + $this->assertEquals($lazyChoiceList, $list1); + $this->assertEquals($lazyChoiceList, $list2); } public function testCreateFromLoaderSameLoader() @@ -221,19 +200,13 @@ public function testCreateFromLoaderSameLoader() public function testCreateFromLoaderSameLoaderUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); - $type = $this->createMock(FormTypeInterface::class); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list = new ArrayChoiceList([]); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader) - ->willReturn($list) - ; + $type = new FormType(); + $list1 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader())); + $list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader())); - $this->assertSame($list, $factory->createListFromLoader(ChoiceList::loader($type, $loader))); - $this->assertSame($list, $factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)))); + $this->assertSame($list1, $list2); + $this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list1); + $this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list2); } public function testCreateFromLoaderDifferentLoader() @@ -255,26 +228,15 @@ public function testCreateFromLoaderSameValueClosure() public function testCreateFromLoaderSameValueClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); - $type = $this->createMock(FormTypeInterface::class); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list = new ArrayChoiceList([]); + $type = new FormType(); + $loader = new ArrayChoiceLoader(); $closure = function () {}; + $list1 = $this->factory->createListFromLoader(ChoiceList::loader($type, $loader), ChoiceList::value($type, $closure)); + $list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), ChoiceList::value($type, function () {})); - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $closure) - ->willReturn($list) - ; - - $this->assertSame($list, $factory->createListFromLoader( - ChoiceList::loader($type, $loader), - ChoiceList::value($type, $closure) - )); - $this->assertSame($list, $factory->createListFromLoader( - ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), - ChoiceList::value($type, function () {}) - )); + $this->assertSame($list1, $list2); + $this->assertEquals(new LazyChoiceList($loader, $closure), $list1); + $this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), function () {}), $list2); } public function testCreateFromLoaderDifferentValueClosure() @@ -288,68 +250,41 @@ public function testCreateFromLoaderDifferentValueClosure() public function testCreateFromLoaderSameFilterClosure() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $type = $this->createMock(FormTypeInterface::class); - $list = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); + $loader = new ArrayChoiceLoader(); + $type = new FormType(); $closure = function () {}; - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromLoader') - ->with($loader, null, $closure) - ->willReturnOnConsecutiveCalls($list, $list2); + $list1 = $this->factory->createListFromLoader(ChoiceList::loader($type, $loader), null, $closure); + $list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $closure); - $this->assertSame($list, $factory->createListFromLoader(ChoiceList::loader($type, $loader), null, $closure)); - $this->assertSame($list2, $factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), null, $closure)); + $this->assertNotSame($list1, $list2); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $closure)), $list1); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure)), $list2); } public function testCreateFromLoaderSameFilterClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); - $type = $this->createMock(FormTypeInterface::class); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $list = new ArrayChoiceList([]); - $closure = function () {}; - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, null, $closure) - ->willReturn($list) - ; + $type = new FormType(); + $choiceFilter = ChoiceList::filter($type, function () {}); + $list1 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $choiceFilter); + $list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $choiceFilter); - $this->assertSame($list, $factory->createListFromLoader( - ChoiceList::loader($type, $loader), - null, - ChoiceList::filter($type, $closure) - )); - $this->assertSame($list, $factory->createListFromLoader( - ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), - null, - ChoiceList::filter($type, function () {}) - )); + $this->assertSame($list1, $list2); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list1); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list2); } public function testCreateFromLoaderDifferentFilterClosure() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $type = $this->createMock(FormTypeInterface::class); - $list1 = new ArrayChoiceList([]); - $list2 = new ArrayChoiceList([]); + $type = new FormType(); $closure1 = function () {}; $closure2 = function () {}; + $list1 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $closure1); + $list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $closure2); - $this->decoratedFactory->expects($this->exactly(2)) - ->method('createListFromLoader') - ->withConsecutive( - [$loader, null, $closure1], - [$loader, null, $closure2] - ) - ->willReturnOnConsecutiveCalls($list1, $list2); - - $this->assertSame($list1, $factory->createListFromLoader(ChoiceList::loader($type, $loader), null, $closure1)); - $this->assertSame($list2, $factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), null, $closure2)); + $this->assertNotSame($list1, $list2); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure1), null), $list1); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure2), null), $list2); } public function testCreateViewSamePreferredChoices() @@ -366,20 +301,15 @@ public function testCreateViewSamePreferredChoices() public function testCreateViewSamePreferredChoicesUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $preferred = ['a']; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $preferred) - ->willReturn($view) - ; + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, ChoiceList::preferred($type, $preferred)); + $view2 = $this->factory->createView($list, ChoiceList::preferred($type, ['a'])); - $this->assertSame($view, $factory->createView($list, ChoiceList::preferred($type, $preferred))); - $this->assertSame($view, $factory->createView($list, ChoiceList::preferred($type, ['a']))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentPreferredChoices() @@ -409,20 +339,15 @@ public function testCreateViewSamePreferredChoicesClosure() public function testCreateViewSamePreferredChoicesClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $preferredCallback = function () {}; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, $preferredCallback) - ->willReturn($view) - ; + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, ChoiceList::preferred($type, $preferredCallback)); + $view2 = $this->factory->createView($list, ChoiceList::preferred($type, function () {})); - $this->assertSame($view, $factory->createView($list, ChoiceList::preferred($type, $preferredCallback))); - $this->assertSame($view, $factory->createView($list, ChoiceList::preferred($type, function () {}))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentPreferredChoicesClosure() @@ -452,20 +377,15 @@ public function testCreateViewSameLabelClosure() public function testCreateViewSameLabelClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $labelsCallback = function () {}; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, $labelsCallback) - ->willReturn($view) - ; + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, ChoiceList::label($type, $labelsCallback)); + $view2 = $this->factory->createView($list, null, ChoiceList::label($type, function () {})); - $this->assertSame($view, $factory->createView($list, null, ChoiceList::label($type, $labelsCallback))); - $this->assertSame($view, $factory->createView($list, null, ChoiceList::label($type, function () {}))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentLabelClosure() @@ -495,20 +415,15 @@ public function testCreateViewSameIndexClosure() public function testCreateViewSameIndexClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $indexCallback = function () {}; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, $indexCallback) - ->willReturn($view) - ; + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, ChoiceList::fieldName($type, $indexCallback)); + $view2 = $this->factory->createView($list, null, null, ChoiceList::fieldName($type, function () {})); - $this->assertSame($view, $factory->createView($list, null, null, ChoiceList::fieldName($type, $indexCallback))); - $this->assertSame($view, $factory->createView($list, null, null, ChoiceList::fieldName($type, function () {}))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentIndexClosure() @@ -538,20 +453,15 @@ public function testCreateViewSameGroupByClosure() public function testCreateViewSameGroupByClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $groupByCallback = function () {}; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, $groupByCallback) - ->willReturn($view) - ; + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, ChoiceList::groupBy($type, $groupByCallback)); + $view2 = $this->factory->createView($list, null, null, null, ChoiceList::groupBy($type, function () {})); - $this->assertSame($view, $factory->createView($list, null, null, null, ChoiceList::groupBy($type, $groupByCallback))); - $this->assertSame($view, $factory->createView($list, null, null, null, ChoiceList::groupBy($type, function () {}))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentGroupByClosure() @@ -581,19 +491,15 @@ public function testCreateViewSameAttributes() public function testCreateViewSameAttributesUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $attr = ['class' => 'foobar']; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $attr) - ->willReturn($view); + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, null, ChoiceList::attr($type, $attr)); + $view2 = $this->factory->createView($list, null, null, null, null, ChoiceList::attr($type, ['class' => 'foobar'])); - $this->assertSame($view, $factory->createView($list, null, null, null, null, ChoiceList::attr($type, $attr))); - $this->assertSame($view, $factory->createView($list, null, null, null, null, ChoiceList::attr($type, ['class' => 'foobar']))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentAttributes() @@ -624,19 +530,15 @@ public function testCreateViewSameAttributesClosure() public function testCreateViewSameAttributesClosureUseCache() { - $factory = new CachingFactoryDecorator($this->decoratedFactory); $attrCallback = function () {}; - $type = $this->createMock(FormTypeInterface::class); - $list = $this->createMock(ChoiceListInterface::class); - $view = new ChoiceListView(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, $attrCallback) - ->willReturn($view); + $type = new FormType(); + $list = new ArrayChoiceList([]); + $view1 = $this->factory->createView($list, null, null, null, null, ChoiceList::attr($type, $attrCallback)); + $view2 = $this->factory->createView($list, null, null, null, null, ChoiceList::attr($type, function () {})); - $this->assertSame($view, $factory->createView($list, null, null, null, null, ChoiceList::attr($type, $attrCallback))); - $this->assertSame($view, $factory->createView($list, null, null, null, null, ChoiceList::attr($type, function () {}))); + $this->assertSame($view1, $view2); + $this->assertEquals(new ChoiceListView(), $view1); + $this->assertEquals(new ChoiceListView(), $view2); } public function testCreateViewDifferentAttributesClosure() diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index e36fa5379b2c..0fa93ba32db5 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -16,7 +16,6 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\FilterChoiceLoaderDecorator; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; @@ -274,12 +273,11 @@ public function testCreateFromLoaderWithValues() public function testCreateFromLoaderWithFilter() { - $loader = $this->createMock(ChoiceLoaderInterface::class); $filter = function () {}; - $list = $this->factory->createListFromLoader($loader, null, $filter); + $list = $this->factory->createListFromLoader(new ArrayChoiceLoader(), null, $filter); - $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $filter)), $list); + $this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $filter)), $list); } public function testCreateViewFlat() diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 728b8bec79b8..09482fda8964 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -11,13 +11,10 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; @@ -28,11 +25,6 @@ */ class PropertyAccessDecoratorTest extends TestCase { - /** - * @var MockObject&ChoiceListFactoryInterface - */ - private $decoratedFactory; - /** * @var PropertyAccessDecorator */ @@ -40,7 +32,6 @@ class PropertyAccessDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->createMock(ChoiceListFactoryInterface::class); $this->factory = new PropertyAccessDecorator(new DefaultChoiceListFactory()); } @@ -60,44 +51,28 @@ public function testCreateFromChoicesPropertyPathInstance() public function testCreateFromChoicesFilterPropertyPath() { - $factory = new PropertyAccessDecorator($this->decoratedFactory); - $filteredChoices = [ - 'two' => (object) ['property' => 'value 2', 'filter' => true], - ]; + $object1 = (object) ['property' => 'value 1', 'filter' => false]; + $object2 = (object) ['property' => 'value 2', 'filter' => true]; $choices = [ - 'one' => (object) ['property' => 'value 1', 'filter' => false], - ] + $filteredChoices; - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($choices, $value, $callback) { - return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); - }); + 'one' => $object1, + 'two' => $object2, + ]; - $this->assertSame(['value 2' => 'value 2'], $factory->createListFromChoices($choices, 'property', 'filter')->getChoices()); + $this->assertSame(['value 2' => $object2], $this->factory->createListFromChoices($choices, 'property', 'filter')->getChoices()); } public function testCreateFromChoicesFilterPropertyPathInstance() { - $factory = new PropertyAccessDecorator($this->decoratedFactory); - $filteredChoices = [ - 'two' => (object) ['property' => 'value 2', 'filter' => true], - ]; + $object1 = (object) ['property' => 'value 1', 'filter' => false]; + $object2 = (object) ['property' => 'value 2', 'filter' => true]; $choices = [ - 'one' => (object) ['property' => 'value 1', 'filter' => false], - ] + $filteredChoices; - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($choices, $value, $callback) { - return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); - }); + 'one' => $object1, + 'two' => $object2, + ]; $this->assertSame( - ['value 2' => 'value 2'], - $factory->createListFromChoices($choices, new PropertyPath('property'), new PropertyPath('filter'))->getChoices() + ['value 2' => $object2], + $this->factory->createListFromChoices($choices, new PropertyPath('property'), new PropertyPath('filter'))->getChoices() ); } @@ -111,23 +86,15 @@ public function testCreateFromLoaderPropertyPath() public function testCreateFromLoaderFilterPropertyPath() { - $factory = new PropertyAccessDecorator($this->decoratedFactory); - $loader = $this->createMock(ChoiceLoaderInterface::class); - $filteredChoices = [ - 'two' => (object) ['property' => 'value 2', 'filter' => true], - ]; + $object1 = (object) ['property' => 'value 1', 'filter' => false]; + $object2 = (object) ['property' => 'value 2', 'filter' => true]; $choices = [ - 'one' => (object) ['property' => 'value 1', 'filter' => false], - ] + $filteredChoices; - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) - ->willReturnCallback(function ($loader, $value, $callback) use ($choices) { - return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); - }); + 'one' => $object1, + 'two' => $object2, + ]; + $loader = new ArrayChoiceLoader($choices); - $this->assertSame(['value 2' => 'value 2'], $factory->createListFromLoader($loader, 'property', 'filter')->getChoices()); + $this->assertSame(['value 2' => $object2], $this->factory->createListFromLoader($loader, 'property', 'filter')->getChoices()); } // https://github.com/symfony/symfony/issues/5494 diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php index 095322f8baa6..d4cc3ce72a4d 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php @@ -13,41 +13,29 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\FilterChoiceLoaderDecorator; +use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader; class FilterChoiceLoaderDecoratorTest extends TestCase { public function testLoadChoiceList() { - $decorated = $this->createMock(ChoiceLoaderInterface::class); - $decorated->expects($this->once()) - ->method('loadChoiceList') - ->willReturn(new ArrayChoiceList(range(1, 4))) - ; - $filter = function ($choice) { return 0 === $choice % 2; }; - $loader = new FilterChoiceLoaderDecorator($decorated, $filter); + $loader = new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(range(1, 4)), $filter); $this->assertEquals(new ArrayChoiceList([1 => 2, 3 => 4]), $loader->loadChoiceList()); } public function testLoadChoiceListWithGroupedChoices() { - $decorated = $this->createMock(ChoiceLoaderInterface::class); - $decorated->expects($this->once()) - ->method('loadChoiceList') - ->willReturn(new ArrayChoiceList(['units' => range(1, 9), 'tens' => range(10, 90, 10)])) - ; - $filter = function ($choice) { return $choice < 9 && 0 === $choice % 2; }; - $loader = new FilterChoiceLoaderDecorator($decorated, $filter); + $loader = new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(['units' => range(1, 9), 'tens' => range(10, 90, 10)]), $filter); $this->assertEquals(new ArrayChoiceList([ 'units' => [ @@ -63,21 +51,11 @@ public function testLoadValuesForChoices() { $evenValues = [1 => '2', 3 => '4']; - $decorated = $this->createMock(ChoiceLoaderInterface::class); - $decorated->expects($this->never()) - ->method('loadChoiceList') - ; - $decorated->expects($this->once()) - ->method('loadValuesForChoices') - ->with([1 => 2, 3 => 4]) - ->willReturn($evenValues) - ; - $filter = function ($choice) { return 0 === $choice % 2; }; - $loader = new FilterChoiceLoaderDecorator($decorated, $filter); + $loader = new FilterChoiceLoaderDecorator(new ArrayChoiceLoader([range(1, 4)]), $filter); $this->assertSame($evenValues, $loader->loadValuesForChoices(range(1, 4))); } @@ -87,21 +65,11 @@ public function testLoadChoicesForValues() $evenChoices = [1 => 2, 3 => 4]; $values = array_map('strval', range(1, 4)); - $decorated = $this->createMock(ChoiceLoaderInterface::class); - $decorated->expects($this->never()) - ->method('loadChoiceList') - ; - $decorated->expects($this->once()) - ->method('loadChoicesForValues') - ->with($values) - ->willReturn(range(1, 4)) - ; - $filter = function ($choice) { return 0 === $choice % 2; }; - $loader = new FilterChoiceLoaderDecorator($decorated, $filter); + $loader = new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(range(1, 4)), $filter); $this->assertEquals($evenChoices, $loader->loadChoicesForValues($values)); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index 858be09c78cf..08b8caaedd5f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -25,6 +25,8 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper\Fixtures\Issue; +use Symfony\Component\Form\Tests\Fixtures\DummyFormRendererEngine; +use Symfony\Component\Form\Tests\Fixtures\FixedTranslator; use Symfony\Component\PropertyAccess\PropertyPath; use Symfony\Component\Validator\Constraints\File; use Symfony\Component\Validator\ConstraintViolation; @@ -1598,16 +1600,7 @@ public function testBacktrackIfSeveralSubFormsWithSamePropertyPath() public function testMessageWithLabel1() { - $renderer = $this->getMockBuilder(FormRenderer::class) - ->setMethods(null) - ->disableOriginalConstructor() - ->getMock() - ; - $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->any())->method('trans')->willReturnMap([ - ['Name', [], null, null, 'Custom Name'], - ]); - $this->mapper = new ViolationMapper($renderer, $translator); + $this->mapper = new ViolationMapper(new FormRenderer(new DummyFormRendererEngine()), new FixedTranslator(['Name' => 'Custom Name'])); $parent = $this->getForm('parent'); $child = $this->getForm('name', 'name'); @@ -1630,11 +1623,7 @@ public function testMessageWithLabel1() public function testMessageWithLabel2() { - $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->any())->method('trans')->willReturnMap([ - ['options_label', [], null, null, 'Translated Label'], - ]); - $this->mapper = new ViolationMapper(null, $translator); + $this->mapper = new ViolationMapper(null, new FixedTranslator(['options_label' => 'Translated Label'])); $parent = $this->getForm('parent'); @@ -1668,11 +1657,7 @@ public function testMessageWithLabel2() public function testMessageWithLabelFormat1() { - $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->any())->method('trans')->willReturnMap([ - ['form.custom', [], null, null, 'Translated 1st Custom Label'], - ]); - $this->mapper = new ViolationMapper(null, $translator); + $this->mapper = new ViolationMapper(null, new FixedTranslator(['form.custom' => 'Translated 1st Custom Label'])); $parent = $this->getForm('parent'); @@ -1706,11 +1691,7 @@ public function testMessageWithLabelFormat1() public function testMessageWithLabelFormat2() { - $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->any())->method('trans')->willReturnMap([ - ['form_custom-id', [], null, null, 'Translated 2nd Custom Label'], - ]); - $this->mapper = new ViolationMapper(null, $translator); + $this->mapper = new ViolationMapper(null, new FixedTranslator(['form_custom-id' => 'Translated 2nd Custom Label'])); $parent = $this->getForm('parent'); @@ -1826,14 +1807,9 @@ public function testLabelPlaceholderTranslatedWithTranslationParametersMergedFro public function testTranslatorNotCalledWithoutLabel() { - $renderer = $this->getMockBuilder(FormRenderer::class) - ->setMethods(null) - ->disableOriginalConstructor() - ->getMock() - ; $translator = $this->createMock(TranslatorInterface::class); $translator->expects($this->never())->method('trans'); - $this->mapper = new ViolationMapper($renderer, $translator); + $this->mapper = new ViolationMapper(new FormRenderer(new DummyFormRendererEngine()), $translator); $parent = $this->getForm('parent'); $child = $this->getForm('name', 'name'); diff --git a/src/Symfony/Component/Form/Tests/Fixtures/DummyFormRendererEngine.php b/src/Symfony/Component/Form/Tests/Fixtures/DummyFormRendererEngine.php new file mode 100644 index 000000000000..7b13d31afcf6 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/DummyFormRendererEngine.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractRendererEngine; +use Symfony\Component\Form\FormView; + +class DummyFormRendererEngine extends AbstractRendererEngine +{ + public function renderBlock(FormView $view, $resource, $blockName, array $variables = []): string + { + return ''; + } + + protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName): bool + { + return true; + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FixedTranslator.php b/src/Symfony/Component/Form/Tests/Fixtures/FixedTranslator.php new file mode 100644 index 000000000000..ba17b5dd3d99 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/FixedTranslator.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Contracts\Translation\TranslatorInterface; + +class FixedTranslator implements TranslatorInterface +{ + private $translations; + + public function __construct(array $translations) + { + $this->translations = $translations; + } + + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string + { + return $this->translations[$id] ?? $id; + } + + public function getLocale(): string + { + return 'en'; + } +} diff --git a/src/Symfony/Component/Form/Tests/FormRendererTest.php b/src/Symfony/Component/Form/Tests/FormRendererTest.php index 8619ea45045a..3783a9fcc141 100644 --- a/src/Symfony/Component/Form/Tests/FormRendererTest.php +++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php @@ -12,11 +12,10 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\AbstractRendererEngine; use Symfony\Component\Form\Exception\BadMethodCallException; use Symfony\Component\Form\FormRenderer; -use Symfony\Component\Form\FormRendererEngineInterface; use Symfony\Component\Form\FormView; +use Symfony\Component\Form\Tests\Fixtures\DummyFormRendererEngine; class FormRendererTest extends TestCase { @@ -37,21 +36,7 @@ public function testRenderARenderedField() $formView->vars['name'] = 'foo'; $formView->setRendered(); - $engine = $this->createMock(FormRendererEngineInterface::class); - $renderer = new FormRenderer($engine); + $renderer = new FormRenderer(new DummyFormRendererEngine()); $renderer->searchAndRenderBlock($formView, 'row'); } } - -class DummyFormRendererEngine extends AbstractRendererEngine -{ - public function renderBlock(FormView $view, $resource, $blockName, array $variables = []): string - { - return ''; - } - - protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName): bool - { - return true; - } -} From a16b56d7157cba174d40a9ec4394845c6ad0f906 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 18 Apr 2022 19:40:34 +0200 Subject: [PATCH 21/60] improve an assertion --- .../Extension/DataCollector/FormDataCollectorTest.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index 520f707f14df..39009b598c53 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -570,14 +570,8 @@ public function testReset() $this->dataCollector->buildPreliminaryFormTree($form); $this->dataCollector->collectSubmittedData($form); - $this->assertNotSame( - [ - 'forms' => [], - 'forms_by_hash' => [], - 'nb_errors' => 0, - ], - $this->dataCollector->getData() - ); + $this->assertGreaterThan(0, \count($this->dataCollector->getData()['forms'])); + $this->assertGreaterThan(0, \count($this->dataCollector->getData()['forms_by_hash'])); $this->dataCollector->reset(); From c3cb4f5f08eee6fb016a0a8e60506dcbfcd7c729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rokas=20Mikalk=C4=97nas?= Date: Wed, 2 Feb 2022 12:17:50 +0200 Subject: [PATCH 22/60] [Serializer] Support canners in object normalizer --- src/Symfony/Component/Serializer/CHANGELOG.md | 1 + .../Serializer/Normalizer/ObjectNormalizer.php | 4 ++-- .../Tests/Normalizer/Features/ObjectDummy.php | 11 +++++++++++ .../Tests/Normalizer/ObjectNormalizerTest.php | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 9bee69dbd4fb..c2b3ebfb3c6c 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG * Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead * Deprecate supporting denormalization for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead * Deprecate denormalizing to an abstract class in `UidNormalizer` + * Add support for `can*()` methods to `ObjectNormalizer` 6.0 --- diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index 0dbc8bc3e7f9..263959c1d6e7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -86,8 +86,8 @@ protected function extractAttributes(object $object, string $format = null, arra $name = $reflMethod->name; $attributeName = null; - if (str_starts_with($name, 'get') || str_starts_with($name, 'has')) { - // getters and hassers + if (str_starts_with($name, 'get') || str_starts_with($name, 'has') || str_starts_with($name, 'can')) { + // getters, hassers and canners $attributeName = substr($name, 3); if (!$reflClass->hasProperty($attributeName)) { diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php index 69661fd1601c..39f3c354a802 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php @@ -22,6 +22,7 @@ class ObjectDummy private $baz; protected $camelCase; protected $object; + private $go; public function getFoo() { @@ -72,4 +73,14 @@ public function getObject() { return $this->object; } + + public function setGo($go) + { + $this->go = $go; + } + + public function canGo() + { + return $this->go; + } } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 244bf94987d4..f7b5dc88d410 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -107,6 +107,7 @@ public function testNormalize() $obj->setBaz(true); $obj->setCamelCase('camelcase'); $obj->setObject($object); + $obj->setGo(true); $this->serializer ->expects($this->once()) @@ -123,6 +124,7 @@ public function testNormalize() 'fooBar' => 'foobar', 'camelCase' => 'camelcase', 'object' => 'string_object', + 'go' => true, ], $this->normalizer->normalize($obj, 'any') ); @@ -669,6 +671,7 @@ public function testNormalizeNotSerializableContext() 'camelCase' => null, 'object' => null, 'bar' => null, + 'go' => null, ]; $this->assertEquals($expected, $this->normalizer->normalize($objectDummy, null, ['not_serializable' => function () { @@ -805,6 +808,7 @@ public function testDefaultObjectClassResolver() $obj->setBaz(true); $obj->setCamelCase('camelcase'); $obj->unwantedProperty = 'notwanted'; + $obj->setGo(false); $this->assertEquals( [ @@ -814,6 +818,7 @@ public function testDefaultObjectClassResolver() 'fooBar' => 'foobar', 'camelCase' => 'camelcase', 'object' => null, + 'go' => false, ], $normalizer->normalize($obj, 'any') ); @@ -842,6 +847,7 @@ public function testObjectClassResolver() 'fooBar' => 'foobar', 'camelCase' => 'camelcase', 'object' => null, + 'go' => null, ], $normalizer->normalize($obj, 'any') ); From 07136a98679a6d85c079e1747003bc7f6effb2de Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Mon, 18 Apr 2022 21:30:11 +0200 Subject: [PATCH 23/60] [Routing] fix router base url when default uri has trailing slash --- .../Component/Routing/RequestContext.php | 2 +- .../Routing/Tests/RequestContextTest.php | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/RequestContext.php b/src/Symfony/Component/Routing/RequestContext.php index 8994b266e685..f54c430eeb07 100644 --- a/src/Symfony/Component/Routing/RequestContext.php +++ b/src/Symfony/Component/Routing/RequestContext.php @@ -98,7 +98,7 @@ public function getBaseUrl() */ public function setBaseUrl(string $baseUrl) { - $this->baseUrl = $baseUrl; + $this->baseUrl = rtrim($baseUrl, '/'); return $this; } diff --git a/src/Symfony/Component/Routing/Tests/RequestContextTest.php b/src/Symfony/Component/Routing/Tests/RequestContextTest.php index 3d23b0e8947a..179ef33d2aae 100644 --- a/src/Symfony/Component/Routing/Tests/RequestContextTest.php +++ b/src/Symfony/Component/Routing/Tests/RequestContextTest.php @@ -40,6 +40,51 @@ public function testConstruct() $this->assertEquals('bar=foobar', $requestContext->getQueryString()); } + public function testFromUriWithBaseUrl() + { + $requestContext = RequestContext::fromUri('https://test.com:444/index.php'); + + $this->assertSame('GET', $requestContext->getMethod()); + $this->assertSame('https', $requestContext->getScheme()); + $this->assertSame('test.com', $requestContext->getHost()); + $this->assertSame('/index.php', $requestContext->getBaseUrl()); + $this->assertSame('/', $requestContext->getPathInfo()); + $this->assertSame(80, $requestContext->getHttpPort()); + $this->assertSame(444, $requestContext->getHttpsPort()); + } + + public function testFromUriWithTrailingSlash() + { + $requestContext = RequestContext::fromUri('http://test.com:8080/'); + + $this->assertSame('http', $requestContext->getScheme()); + $this->assertSame('test.com', $requestContext->getHost()); + $this->assertSame(8080, $requestContext->getHttpPort()); + $this->assertSame(443, $requestContext->getHttpsPort()); + $this->assertSame('', $requestContext->getBaseUrl()); + $this->assertSame('/', $requestContext->getPathInfo()); + } + + public function testFromUriWithoutTrailingSlash() + { + $requestContext = RequestContext::fromUri('https://test.com'); + + $this->assertSame('https', $requestContext->getScheme()); + $this->assertSame('test.com', $requestContext->getHost()); + $this->assertSame('', $requestContext->getBaseUrl()); + $this->assertSame('/', $requestContext->getPathInfo()); + } + + public function testFromUriBeingEmpty() + { + $requestContext = RequestContext::fromUri(''); + + $this->assertSame('http', $requestContext->getScheme()); + $this->assertSame('localhost', $requestContext->getHost()); + $this->assertSame('', $requestContext->getBaseUrl()); + $this->assertSame('/', $requestContext->getPathInfo()); + } + public function testFromRequest() { $request = Request::create('https://test.com:444/foo?bar=baz'); From f4bdd82c8c95c1c3c73a7c7fefa286566069c587 Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Sun, 20 Feb 2022 14:24:12 +0100 Subject: [PATCH 24/60] Restore PHP8 features for Doctrine debug middlewares --- .../DataCollector/DoctrineDataCollector.php | 10 +- .../Doctrine/Middleware/Debug/Connection.php | 95 +++++-------------- .../Middleware/Debug/DebugDataHolder.php | 2 +- .../Doctrine/Middleware/Debug/Driver.php | 18 ++-- .../Doctrine/Middleware/Debug/Middleware.php | 14 +-- .../Doctrine/Middleware/Debug/Query.php | 28 ++---- .../Doctrine/Middleware/Debug/Statement.php | 14 +-- .../Tests/Middleware/Debug/MiddlewareTest.php | 49 +++------- 8 files changed, 71 insertions(+), 159 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index 7acc2e8e96e9..c5318414dbf6 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -29,22 +29,20 @@ */ class DoctrineDataCollector extends DataCollector { - private ManagerRegistry $registry; private array $connections; private array $managers; - private ?DebugDataHolder $debugDataHolder; /** * @var array */ private array $loggers = []; - public function __construct(ManagerRegistry $registry, DebugDataHolder $debugDataHolder = null) - { - $this->registry = $registry; + public function __construct( + private ManagerRegistry $registry, + private ?DebugDataHolder $debugDataHolder = null, + ) { $this->connections = $registry->getConnectionNames(); $this->managers = $registry->getManagerNames(); - $this->debugDataHolder = $debugDataHolder; } /** diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php index d085b0af0e3d..27eb35c004ab 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php @@ -24,18 +24,15 @@ */ final class Connection extends AbstractConnectionMiddleware { - private $nestingLevel = 0; - private $debugDataHolder; - private $stopwatch; - private $connectionName; - - public function __construct(ConnectionInterface $connection, DebugDataHolder $debugDataHolder, ?Stopwatch $stopwatch, string $connectionName) - { + private int $nestingLevel = 0; + + public function __construct( + ConnectionInterface $connection, + private DebugDataHolder $debugDataHolder, + private ?Stopwatch $stopwatch, + private string $connectionName, + ) { parent::__construct($connection); - - $this->debugDataHolder = $debugDataHolder; - $this->stopwatch = $stopwatch; - $this->connectionName = $connectionName; } public function prepare(string $sql): DriverStatement @@ -44,7 +41,7 @@ public function prepare(string $sql): DriverStatement parent::prepare($sql), $this->debugDataHolder, $this->connectionName, - $sql + $sql, ); } @@ -52,20 +49,14 @@ public function query(string $sql): Result { $this->debugDataHolder->addQuery($this->connectionName, $query = new Query($sql)); - if (null !== $this->stopwatch) { - $this->stopwatch->start('doctrine', 'doctrine'); - } - + $this->stopwatch?->start('doctrine', 'doctrine'); $query->start(); try { $result = parent::query($sql); } finally { $query->stop(); - - if (null !== $this->stopwatch) { - $this->stopwatch->stop('doctrine'); - } + $this->stopwatch?->stop('doctrine'); } return $result; @@ -75,20 +66,14 @@ public function exec(string $sql): int { $this->debugDataHolder->addQuery($this->connectionName, $query = new Query($sql)); - if (null !== $this->stopwatch) { - $this->stopwatch->start('doctrine', 'doctrine'); - } - + $this->stopwatch?->start('doctrine', 'doctrine'); $query->start(); try { $affectedRows = parent::exec($sql); } finally { $query->stop(); - - if (null !== $this->stopwatch) { - $this->stopwatch->stop('doctrine'); - } + $this->stopwatch?->stop('doctrine'); } return $affectedRows; @@ -101,24 +86,14 @@ public function beginTransaction(): bool $this->debugDataHolder->addQuery($this->connectionName, $query = new Query('"START TRANSACTION"')); } - if (null !== $this->stopwatch) { - $this->stopwatch->start('doctrine', 'doctrine'); - } - - if (null !== $query) { - $query->start(); - } + $this->stopwatch?->start('doctrine', 'doctrine'); + $query?->start(); try { $ret = parent::beginTransaction(); } finally { - if (null !== $query) { - $query->stop(); - } - - if (null !== $this->stopwatch) { - $this->stopwatch->stop('doctrine'); - } + $query?->stop(); + $this->stopwatch?->stop('doctrine'); } return $ret; @@ -131,24 +106,14 @@ public function commit(): bool $this->debugDataHolder->addQuery($this->connectionName, $query = new Query('"COMMIT"')); } - if (null !== $this->stopwatch) { - $this->stopwatch->start('doctrine', 'doctrine'); - } - - if (null !== $query) { - $query->start(); - } + $this->stopwatch?->start('doctrine', 'doctrine'); + $query?->start(); try { $ret = parent::commit(); } finally { - if (null !== $query) { - $query->stop(); - } - - if (null !== $this->stopwatch) { - $this->stopwatch->stop('doctrine'); - } + $query?->stop(); + $this->stopwatch?->stop('doctrine'); } return $ret; @@ -161,24 +126,14 @@ public function rollBack(): bool $this->debugDataHolder->addQuery($this->connectionName, $query = new Query('"ROLLBACK"')); } - if (null !== $this->stopwatch) { - $this->stopwatch->start('doctrine', 'doctrine'); - } - - if (null !== $query) { - $query->start(); - } + $this->stopwatch?->start('doctrine', 'doctrine'); + $query?->start(); try { $ret = parent::rollBack(); } finally { - if (null !== $query) { - $query->stop(); - } - - if (null !== $this->stopwatch) { - $this->stopwatch->stop('doctrine'); - } + $query?->stop(); + $this->stopwatch?->stop('doctrine'); } return $ret; diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php index 2643cc749383..14c338e63d69 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php @@ -16,7 +16,7 @@ */ class DebugDataHolder { - private $data = []; + private array $data = []; public function addQuery(string $connectionName, Query $query): void { diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php index 7f7fdd3bf0d8..c66bed90d08f 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php @@ -22,17 +22,13 @@ */ final class Driver extends AbstractDriverMiddleware { - private $debugDataHolder; - private $stopwatch; - private $connectionName; - - public function __construct(DriverInterface $driver, DebugDataHolder $debugDataHolder, ?Stopwatch $stopwatch, string $connectionName) - { + public function __construct( + DriverInterface $driver, + private DebugDataHolder $debugDataHolder, + private ?Stopwatch $stopwatch, + private string $connectionName, + ) { parent::__construct($driver); - - $this->debugDataHolder = $debugDataHolder; - $this->stopwatch = $stopwatch; - $this->connectionName = $connectionName; } public function connect(array $params): Connection @@ -41,7 +37,7 @@ public function connect(array $params): Connection parent::connect($params), $this->debugDataHolder, $this->stopwatch, - $this->connectionName + $this->connectionName, ); } } diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Middleware.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Middleware.php index 18f6a58d5e7a..56b03f51335a 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Middleware.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Middleware.php @@ -22,15 +22,11 @@ */ final class Middleware implements MiddlewareInterface { - private $debugDataHolder; - private $stopwatch; - private $connectionName; - - public function __construct(DebugDataHolder $debugDataHolder, ?Stopwatch $stopwatch, string $connectionName = 'default') - { - $this->debugDataHolder = $debugDataHolder; - $this->stopwatch = $stopwatch; - $this->connectionName = $connectionName; + public function __construct( + private DebugDataHolder $debugDataHolder, + private ?Stopwatch $stopwatch, + private string $connectionName = 'default', + ) { } public function wrap(DriverInterface $driver): DriverInterface diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php index d652f620ce2e..dc8c9d79ae1f 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php @@ -20,17 +20,15 @@ */ class Query { - private $params = []; - private $types = []; + private array $params = []; + private array $types = []; - private $start; - private $duration; + private ?float $start = null; + private ?float $duration = null; - private $sql; - - public function __construct(string $sql) - { - $this->sql = $sql; + public function __construct( + private string $sql, + ) { } public function start(): void @@ -45,11 +43,7 @@ public function stop(): void } } - /** - * @param string|int $param - * @param string|int|float|bool|null $variable - */ - public function setParam($param, &$variable, int $type): void + public function setParam(string|int $param, null|string|int|float|bool &$variable, int $type): void { // Numeric indexes start at 0 in profiler $idx = \is_int($param) ? $param - 1 : $param; @@ -58,11 +52,7 @@ public function setParam($param, &$variable, int $type): void $this->types[$idx] = $type; } - /** - * @param string|int $param - * @param string|int|float|bool|null $value - */ - public function setValue($param, $value, int $type): void + public function setValue(string|int $param, null|string|int|float|bool $value, int $type): void { // Numeric indexes start at 0 in profiler $idx = \is_int($param) ? $param - 1 : $param; diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Statement.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Statement.php index e52530e906dc..0157c5db11e8 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Statement.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Statement.php @@ -23,16 +23,16 @@ */ final class Statement extends AbstractStatementMiddleware { - private $debugDataHolder; - private $connectionName; - private $query; + private Query $query; - public function __construct(StatementInterface $statement, DebugDataHolder $debugDataHolder, string $connectionName, string $sql) - { + public function __construct( + StatementInterface $statement, + private DebugDataHolder $debugDataHolder, + private string $connectionName, + string $sql, + ) { parent::__construct($statement); - $this->debugDataHolder = $debugDataHolder; - $this->connectionName = $connectionName; $this->query = new Query($sql); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php index d1243f5f03d4..3a461a63749b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php @@ -16,7 +16,7 @@ use Doctrine\DBAL\Driver\Middleware as MiddlewareInterface; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\ParameterType; -use Doctrine\DBAL\Result; +use Doctrine\DBAL\Statement; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder; use Symfony\Bridge\Doctrine\Middleware\Debug\Middleware; @@ -28,9 +28,9 @@ */ class MiddlewareTest extends TestCase { - private $debugDataHolder; - private $conn; - private $stopwatch; + private DebugDataHolder $debugDataHolder; + private Connection $conn; + private ?Stopwatch $stopwatch; protected function setUp(): void { @@ -63,22 +63,17 @@ private function init(bool $withStopwatch = true): void price REAL NOT NULL, stock INTEGER NOT NULL ); -EOT - ); +EOT); } public function provideExecuteMethod(): array { return [ 'executeStatement' => [ - static function (object $target, ...$args) { - return $target->executeStatement(...$args); - }, + static fn (Statement|Connection $target, mixed ...$args) => $target->executeStatement(...$args), ], 'executeQuery' => [ - static function (object $target, ...$args): Result { - return $target->executeQuery(...$args); - }, + static fn (Statement|Connection $target, mixed ...$args) => $target->executeQuery(...$args), ], ]; } @@ -156,18 +151,8 @@ public function testWithParamBound(callable $executeMethod) public function provideEndTransactionMethod(): array { return [ - 'commit' => [ - static function (Connection $conn): bool { - return $conn->commit(); - }, - '"COMMIT"', - ], - 'rollback' => [ - static function (Connection $conn): bool { - return $conn->rollBack(); - }, - '"ROLLBACK"', - ], + 'commit' => [static fn (Connection $conn) => $conn->commit(), '"COMMIT"'], + 'rollback' => [static fn (Connection $conn) => $conn->rollBack(), '"ROLLBACK"'], ]; } @@ -207,20 +192,12 @@ public function provideExecuteAndEndTransactionMethods(): array { return [ 'commit and exec' => [ - static function (Connection $conn, string $sql) { - return $conn->executeStatement($sql); - }, - static function (Connection $conn): bool { - return $conn->commit(); - }, + static fn (Connection $conn, string $sql) => $conn->executeStatement($sql), + static fn (Connection $conn) => $conn->commit(), ], 'rollback and query' => [ - static function (Connection $conn, string $sql): Result { - return $conn->executeQuery($sql); - }, - static function (Connection $conn): bool { - return $conn->rollBack(); - }, + static fn (Connection $conn, string $sql) => $conn->executeQuery($sql), + static fn (Connection $conn) => $conn->rollBack(), ], ]; } From a506f9c517ef175d9ea4f1c9d504dcfa0430af4a Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 19 Apr 2022 10:53:48 +0200 Subject: [PATCH 25/60] [VarDumper] Remove casters for mysql link resource and removed DOM classes --- .../Component/VarDumper/Caster/DOMCaster.php | 37 ------------------- .../VarDumper/Caster/ResourceCaster.php | 9 ----- .../VarDumper/Cloner/AbstractCloner.php | 4 -- 3 files changed, 50 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php index 4dd16e0ee746..8b770b8ae387 100644 --- a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php @@ -208,43 +208,6 @@ public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNes return $a; } - public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, bool $isNested) - { - $a += [ - 'typeName' => $dom->typeName, - 'typeNamespace' => $dom->typeNamespace, - ]; - - return $a; - } - - public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, bool $isNested) - { - $a += [ - 'severity' => $dom->severity, - 'message' => $dom->message, - 'type' => $dom->type, - 'relatedException' => $dom->relatedException, - 'related_data' => $dom->related_data, - 'location' => $dom->location, - ]; - - return $a; - } - - public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, bool $isNested) - { - $a += [ - 'lineNumber' => $dom->lineNumber, - 'columnNumber' => $dom->columnNumber, - 'offset' => $dom->offset, - 'relatedNode' => $dom->relatedNode, - 'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri, - ]; - - return $a; - } - public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested) { $a += [ diff --git a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php index 4e597f86d492..f1229446597d 100644 --- a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php @@ -63,15 +63,6 @@ public static function castGd($gd, array $a, Stub $stub, bool $isNested) return $a; } - public static function castMysqlLink($h, array $a, Stub $stub, bool $isNested) - { - $a['host'] = mysql_get_host_info($h); - $a['protocol'] = mysql_get_proto_info($h); - $a['server'] = mysql_get_server_info($h); - - return $a; - } - public static function castOpensslX509($h, array $a, Stub $stub, bool $isNested) { $stub->cut = -1; diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index b835c0336896..636c39ee2b71 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -66,9 +66,6 @@ abstract class AbstractCloner implements ClonerInterface 'DOMAttr' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castAttr'], 'DOMElement' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castElement'], 'DOMText' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castText'], - 'DOMTypeinfo' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castTypeinfo'], - 'DOMDomError' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDomError'], - 'DOMLocator' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLocator'], 'DOMDocumentType' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocumentType'], 'DOMNotation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNotation'], 'DOMEntity' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castEntity'], @@ -163,7 +160,6 @@ abstract class AbstractCloner implements ClonerInterface 'GdImage' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'], ':gd' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'], - ':mysql link' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castMysqlLink'], ':pgsql large object' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLargeObject'], ':pgsql link' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'], ':pgsql link persistent' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'], From 8a07636da6af07a057def6731ca869eac7d6df35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Koz=C5=82owski?= Date: Fri, 15 Apr 2022 08:30:05 +0200 Subject: [PATCH 26/60] [Notifier] smsapi - send messages in test mode --- .../Component/Notifier/Bridge/Smsapi/CHANGELOG.md | 3 ++- .../Component/Notifier/Bridge/Smsapi/README.md | 3 ++- .../Notifier/Bridge/Smsapi/SmsapiTransport.php | 13 ++++++++++++- .../Bridge/Smsapi/SmsapiTransportFactory.php | 7 ++++++- .../Smsapi/Tests/SmsapiTransportFactoryTest.php | 8 ++++++++ .../Bridge/Smsapi/Tests/SmsapiTransportTest.php | 2 +- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Smsapi/CHANGELOG.md index 18564bc696b0..bc897c0f88f0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/CHANGELOG.md @@ -4,7 +4,8 @@ CHANGELOG 6.1 --- - * Added `fast` option to the DSN that allows sending message with the highest priority that ensures the quickest possible time of delivery + * Add `fast` option to the DSN that allows sending message with the highest priority that ensures the quickest possible time of delivery + * Add `test` option to the DSN that allows sending message in test mode (message is validated, but not sent) 5.2 --- diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/README.md b/src/Symfony/Component/Notifier/Bridge/Smsapi/README.md index dc1c6230273a..55b7a67643b0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/README.md @@ -7,13 +7,14 @@ DSN example ----------- ``` -SMSAPI_DSN=smsapi://TOKEN@default?from=FROM&fast=FAST +SMSAPI_DSN=smsapi://TOKEN@default?from=FROM&fast=FAST&test=TEST ``` where: - `TOKEN` is your API Token (OAuth) - `FROM` is the sender name - `FAST` setting this parameter to "1" (default "0") will result in sending message with the highest priority which ensures the quickest possible time of delivery. Attention! Fast messages cost more than normal messages. + - `TEST` setting this parameter to "1" (default "0") will result in sending message in test mode (message is validated, but not sent). See your account info at https://ssl.smsapi.pl/ diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php index 98d6fa7dedd6..3f6fdc214a7e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php @@ -32,6 +32,7 @@ final class SmsapiTransport extends AbstractTransport private string $authToken; private string $from; private bool $fast = false; + private bool $test = false; public function __construct(string $authToken, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { @@ -51,6 +52,16 @@ public function setFast(bool $fast): static return $this; } + /** + * @return $this + */ + public function setTest(bool $test): static + { + $this->test = $test; + + return $this; + } + public function __toString(): string { return sprintf('smsapi://%s?from=%s&fast=%d', $this->getEndpoint(), $this->from, (int) $this->fast); @@ -75,9 +86,9 @@ protected function doSend(MessageInterface $message): SentMessage 'to' => $message->getPhone(), 'message' => $message->getSubject(), 'fast' => $this->fast, - 'encoding' => 'utf-8', 'format' => 'json', 'encoding' => 'utf-8', + 'test' => $this->test, ], ]); diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php index 5f1d3803eee1..75caaffb24e8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php @@ -32,9 +32,14 @@ public function create(Dsn $dsn): SmsapiTransport $from = $dsn->getRequiredOption('from'); $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); $fast = filter_var($dsn->getOption('fast', false), \FILTER_VALIDATE_BOOLEAN); + $test = filter_var($dsn->getOption('test', false), \FILTER_VALIDATE_BOOLEAN); $port = $dsn->getPort(); - return (new SmsapiTransport($authToken, $from, $this->client, $this->dispatcher))->setFast($fast)->setHost($host)->setPort($port); + return (new SmsapiTransport($authToken, $from, $this->client, $this->dispatcher)) + ->setFast($fast) + ->setHost($host) + ->setPort($port) + ->setTest($test); } protected function getSupportedSchemes(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php index 4f312a95f140..098af9af69c8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php @@ -26,21 +26,28 @@ public function createProvider(): iterable yield [ 'smsapi://host.test?from=testFrom&fast=0', 'smsapi://token@host.test?from=testFrom', + 'smsapi://token@host.test?from=testFrom&fast=0&test=0', ]; yield [ 'smsapi://host.test?from=testFrom&fast=0', 'smsapi://token@host.test?from=testFrom&fast=0', + 'smsapi://token@host.test?from=testFrom&fast=1&test=0', + 'smsapi://token@host.test?from=testFrom&test=0', ]; yield [ 'smsapi://host.test?from=testFrom&fast=1', 'smsapi://token@host.test?from=testFrom&fast=1', + 'smsapi://token@host.test?from=testFrom&fast=1&test=1', + 'smsapi://token@host.test?from=testFrom&test=1', ]; yield [ 'smsapi://host.test?from=testFrom&fast=1', 'smsapi://token@host.test?from=testFrom&fast=true', + 'smsapi://token@host.test?from=testFrom&fast=true&test=true', + 'smsapi://token@host.test?from=testFrom&test=true', ]; } @@ -48,6 +55,7 @@ public function supportsProvider(): iterable { yield [true, 'smsapi://host?from=testFrom']; yield [true, 'smsapi://host?from=testFrom&fast=1']; + yield [true, 'smsapi://host?from=testFrom&fast=1&test=1']; yield [false, 'somethingElse://host?from=testFrom']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php index fcc89feb8bcd..e8eb203792c6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php @@ -25,7 +25,7 @@ final class SmsapiTransportTest extends TransportTestCase { public function createTransport(HttpClientInterface $client = null): SmsapiTransport { - return (new SmsapiTransport('testToken', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setFast(true)->setHost('test.host'); + return (new SmsapiTransport('testToken', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setFast(true)->setHost('test.host')->setTest(true); } public function toStringProvider(): iterable From 8acf157b1301bb22500d40e2cba277559b4513b9 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Fri, 15 Apr 2022 14:36:32 +0200 Subject: [PATCH 27/60] [PropertyInfo] Add support for promoted properties in PhpStanExtractor --- src/Symfony/Component/PropertyInfo/CHANGELOG.md | 1 + .../PropertyInfo/Extractor/PhpStanExtractor.php | 16 +++++++++++----- .../Tests/Extractor/PhpStanExtractorTest.php | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/PropertyInfo/CHANGELOG.md b/src/Symfony/Component/PropertyInfo/CHANGELOG.md index 6d408eb87e39..3595f75017c6 100644 --- a/src/Symfony/Component/PropertyInfo/CHANGELOG.md +++ b/src/Symfony/Component/PropertyInfo/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Add support for phpDocumentor and PHPStan pseudo-types * Add PHP 8.0 promoted properties `@param` mutation support to `PhpDocExtractor` + * Add PHP 8.0 promoted properties `@param` mutation support to `PhpStanExtractor` 6.0 --- diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php index 89721f4e666a..db25e14f4473 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php @@ -196,8 +196,8 @@ private function getDocBlock(string $class, string $property): array $ucFirstProperty = ucfirst($property); - if ([$docBlock, $declaringClass] = $this->getDocBlockFromProperty($class, $property)) { - $data = [$docBlock, self::PROPERTY, null, $declaringClass]; + if ([$docBlock, $source, $declaringClass] = $this->getDocBlockFromProperty($class, $property)) { + $data = [$docBlock, $source, null, $declaringClass]; } elseif ([$docBlock, $_, $declaringClass] = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::ACCESSOR)) { $data = [$docBlock, self::ACCESSOR, null, $declaringClass]; } elseif ([$docBlock, $prefix, $declaringClass] = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::MUTATOR)) { @@ -210,7 +210,7 @@ private function getDocBlock(string $class, string $property): array } /** - * @return array{PhpDocNode, string}|null + * @return array{PhpDocNode, int, string}|null */ private function getDocBlockFromProperty(string $class, string $property): ?array { @@ -221,7 +221,13 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra return null; } - if (null === $rawDocNode = $reflectionProperty->getDocComment() ?: null) { + $source = self::PROPERTY; + + if ($reflectionProperty->isPromoted()) { + $constructor = new \ReflectionMethod($class, '__construct'); + $rawDocNode = $constructor->getDocComment(); + $source = self::MUTATOR; + } elseif (null === $rawDocNode = $reflectionProperty->getDocComment() ?: null) { return null; } @@ -229,7 +235,7 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra $phpDocNode = $this->phpDocParser->parse($tokens); $tokens->consumeTokenType(Lexer::TOKEN_END); - return [$phpDocNode, $reflectionProperty->class]; + return [$phpDocNode, $source, $reflectionProperty->class]; } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php index 26077f7e528d..0cf346fce03c 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php @@ -17,6 +17,7 @@ use Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue; use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy; use Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy; +use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy; use Symfony\Component\PropertyInfo\Tests\Fixtures\RootDummy\RootDummyItem; use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsedInTrait; use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsingTrait; @@ -434,6 +435,21 @@ public function testDummyNamespaceWithProperty() $this->assertEquals('A\Property', $phpStanTypes[0]->getClassName()); $this->assertEquals($phpDocTypes[0]->getClassName(), $phpStanTypes[0]->getClassName()); } + + /** + * @dataProvider php80TypesProvider + */ + public function testExtractPhp80Type($property, array $type = null) + { + $this->assertEquals($type, $this->extractor->getTypes(Php80Dummy::class, $property, [])); + } + + public function php80TypesProvider() + { + return [ + ['promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]], + ]; + } } class PhpStanOmittedParamTagTypeDocBlock From acefeb9b5a328e9c606ef86205d1fab269586c0e Mon Sep 17 00:00:00 2001 From: HypeMC Date: Thu, 14 Apr 2022 09:22:15 +0200 Subject: [PATCH 28/60] [Routing] Add route_parameters variable to condition expression --- UPGRADE-6.2.md | 7 ++++ src/Symfony/Component/Routing/CHANGELOG.md | 6 ++++ .../Dumper/CompiledUrlMatcherDumper.php | 4 +-- .../Dumper/CompiledUrlMatcherTrait.php | 33 +++++++++---------- .../Routing/Matcher/TraceableUrlMatcher.php | 6 ++-- .../Component/Routing/Matcher/UrlMatcher.php | 25 +++++++++++--- .../Fixtures/dumper/compiled_url_matcher3.php | 9 +++-- .../Dumper/CompiledUrlMatcherDumperTest.php | 4 +++ .../Tests/Matcher/TraceableUrlMatcherTest.php | 9 +++++ .../Routing/Tests/Matcher/UrlMatcherTest.php | 31 +++++++++++++++++ 10 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 UPGRADE-6.2.md diff --git a/UPGRADE-6.2.md b/UPGRADE-6.2.md new file mode 100644 index 000000000000..4dc684cab8f7 --- /dev/null +++ b/UPGRADE-6.2.md @@ -0,0 +1,7 @@ +UPGRADE FROM 6.1 to 6.2 +======================= + +Routing +------- + + * Add argument `$routeParameters` to `UrlMatcher::handleRouteRequirements()` diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 36181ac71600..8d6f80a15299 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +6.2 +--- + + * Add `params` variable to condition expression + * Deprecate not passing route parameters as the forth argument to `UrlMatcher::handleRouteRequirements()` + 6.1 --- diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php index 8aba7d74e588..c3953d08e44c 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php @@ -115,7 +115,7 @@ public function getCompiledRoutes(bool $forDump = false): array } $checkConditionCode = <<indent(implode("\n", $conditions), 3)} } @@ -426,7 +426,7 @@ private function compileRoute(Route $route, string $name, string|array|null $var } if ($condition = $route->getCondition()) { - $condition = $this->getExpressionLanguage()->compile($condition, ['context', 'request']); + $condition = $this->getExpressionLanguage()->compile($condition, ['context', 'request', 'params']); $condition = $conditions[$condition] ??= (str_contains($condition, '$request') ? 1 : -1) * \count($conditions); } else { $condition = null; diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php index 7e869e049196..207d054fb3ed 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php @@ -92,10 +92,6 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche $supportsRedirections = 'GET' === $canonicalMethod && $this instanceof RedirectableUrlMatcherInterface; foreach ($this->staticRoutes[$trimmedPathinfo] ?? [] as [$ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition]) { - if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ??= $this->request ?: $this->createRequest($pathinfo) : null)) { - continue; - } - if ($requiredHost) { if ('{' !== $requiredHost[0] ? $requiredHost !== $host : !preg_match($requiredHost, $host, $hostMatches)) { continue; @@ -106,6 +102,10 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche } } + if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ??= $this->request ?: $this->createRequest($pathinfo) : null, $ret)) { + continue; + } + if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) { if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) { return $allow = $allowSchemes = []; @@ -132,13 +132,8 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche foreach ($this->regexpList as $offset => $regex) { while (preg_match($regex, $matchedPathinfo, $matches)) { foreach ($this->dynamicRoutes[$m = (int) $matches['MARK']] as [$ret, $vars, $requiredMethods, $requiredSchemes, $hasTrailingSlash, $hasTrailingVar, $condition]) { - if (null !== $condition) { - if (0 === $condition) { // marks the last route in the regexp - continue 3; - } - if (!($this->checkCondition)($condition, $context, 0 < $condition ? $request ??= $this->request ?: $this->createRequest($pathinfo) : null)) { - continue; - } + if (0 === $condition) { // marks the last route in the regexp + continue 3; } $hasTrailingVar = $trimmedPathinfo !== $pathinfo && $hasTrailingVar; @@ -151,17 +146,21 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche } } - if ('/' !== $pathinfo && !$hasTrailingVar && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) { - if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) { - return $allow = $allowSchemes = []; + foreach ($vars as $i => $v) { + if (isset($matches[1 + $i])) { + $ret[$v] = $matches[1 + $i]; } + } + + if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ??= $this->request ?: $this->createRequest($pathinfo) : null, $ret)) { continue; } - foreach ($vars as $i => $v) { - if (isset($matches[1 + $i])) { - $ret[$v] = $matches[1 + $i]; + if ('/' !== $pathinfo && !$hasTrailingVar && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) { + if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) { + return $allow = $allowSchemes = []; } + continue; } if ($requiredSchemes && !isset($requiredSchemes[$context->getScheme()])) { diff --git a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index 323941e788e2..0f0cb3fd9e6a 100644 --- a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -115,7 +115,9 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a continue; } - $status = $this->handleRouteRequirements($pathinfo, $name, $route); + $attributes = $this->getAttributes($route, $name, array_replace($matches, $hostMatches)); + + $status = $this->handleRouteRequirements($pathinfo, $name, $route, $attributes); if (self::REQUIREMENT_MISMATCH === $status[0]) { $this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $route->getCondition()), self::ROUTE_ALMOST_MATCHES, $name, $route); @@ -146,7 +148,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a $this->addTrace('Route matches!', self::ROUTE_MATCHES, $name, $route); - return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, $status[1] ?? [])); + return array_replace($attributes, $status[1] ?? []); } return []; diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index dc9e09f00cfb..b077c0bc3eb7 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -167,7 +167,9 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a continue; } - $status = $this->handleRouteRequirements($pathinfo, $name, $route); + $attributes = $this->getAttributes($route, $name, array_replace($matches, $hostMatches)); + + $status = $this->handleRouteRequirements($pathinfo, $name, $route, $attributes); if (self::REQUIREMENT_MISMATCH === $status[0]) { continue; @@ -190,7 +192,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a continue; } - return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, $status[1] ?? [])); + return array_replace($attributes, $status[1] ?? []); } return []; @@ -220,10 +222,25 @@ protected function getAttributes(Route $route, string $name, array $attributes): * * @return array The first element represents the status, the second contains additional information */ - protected function handleRouteRequirements(string $pathinfo, string $name, Route $route): array + protected function handleRouteRequirements(string $pathinfo, string $name, Route $route/*, array $routeParameters*/): array { + if (\func_num_args() < 4) { + trigger_deprecation('symfony/routing', '6.2', 'The "%s()" method will have a new "array $routeParameters" argument in version 7.0, not defining it is deprecated.', __METHOD__); + $routeParameters = []; + } else { + $routeParameters = func_get_arg(3); + + if (!\is_array($routeParameters)) { + throw new \TypeError(sprintf('"%s": Argument $routeParameters is expected to be an array, got "%s".', __METHOD__, get_debug_type($routeParameters))); + } + } + // expression condition - if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), ['context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)])) { + if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), [ + 'context' => $this->context, + 'request' => $this->request ?: $this->createRequest($pathinfo), + 'params' => $routeParameters, + ])) { return [self::REQUIREMENT_MISMATCH, null]; } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/compiled_url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/compiled_url_matcher3.php index 4fe52b3c83ca..d74be502c533 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/compiled_url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/compiled_url_matcher3.php @@ -14,17 +14,20 @@ [ // $regexpList 0 => '{^(?' .'|/rootprefix/([^/]++)(*:27)' + .'|/with\\-condition/(\\d+)(*:56)' .')/?$}sD', ], [ // $dynamicRoutes - 27 => [ - [['_route' => 'dynamic'], ['var'], null, null, false, true, null], + 27 => [[['_route' => 'dynamic'], ['var'], null, null, false, true, null]], + 56 => [ + [['_route' => 'with-condition-dynamic'], ['id'], null, null, false, true, -2], [null, null, null, null, false, false, 0], ], ], - static function ($condition, $context, $request) { // $checkCondition + static function ($condition, $context, $request, $params) { // $checkCondition switch ($condition) { case -1: return ($context->getMethod() == "GET"); + case -2: return ($params["id"] < 100); } }, ]; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php index 4886d717685c..0df1c0cf4058 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php @@ -296,6 +296,10 @@ public function getRouteCollections() $route = new Route('/with-condition'); $route->setCondition('context.getMethod() == "GET"'); $rootprefixCollection->add('with-condition', $route); + $route = new Route('/with-condition/{id}'); + $route->setRequirement('id', '\d+'); + $route->setCondition("params['id'] < 100"); + $rootprefixCollection->add('with-condition-dynamic', $route); /* test case 4 */ $headMatchCasesCollection = new RouteCollection(); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php index b33e93caa1a8..03b11a697aa0 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php @@ -104,6 +104,7 @@ public function testRoutesWithConditions() { $routes = new RouteCollection(); $routes->add('foo', new Route('/foo', [], [], [], 'baz', [], [], "request.headers.get('User-Agent') matches '/firefox/i'")); + $routes->add('bar', new Route('/bar/{id}', [], [], [], 'baz', [], [], "params['id'] < 100")); $context = new RequestContext(); $context->setHost('baz'); @@ -117,6 +118,14 @@ public function testRoutesWithConditions() $matchingRequest = Request::create('/foo', 'GET', [], [], [], ['HTTP_USER_AGENT' => 'Firefox']); $traces = $matcher->getTracesForRequest($matchingRequest); $this->assertEquals('Route matches!', $traces[0]['log']); + + $notMatchingRequest = Request::create('/bar/1000', 'GET'); + $traces = $matcher->getTracesForRequest($notMatchingRequest); + $this->assertEquals("Condition \"params['id'] < 100\" does not evaluate to \"true\"", $traces[1]['log']); + + $matchingRequest = Request::create('/bar/10', 'GET'); + $traces = $matcher->getTracesForRequest($matchingRequest); + $this->assertEquals('Route matches!', $traces[1]['log']); } protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null) diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 74ceb1e0be21..41126642e476 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -474,6 +474,37 @@ public function testRequestCondition() $this->assertEquals(['bar' => 'bar', '_route' => 'foo'], $matcher->match('/foo/bar')); } + public function testRouteParametersCondition() + { + $coll = new RouteCollection(); + $route = new Route('/foo'); + $route->setCondition("params['_route'] matches '/^s[a-z]+$/'"); + $coll->add('static', $route); + $route = new Route('/bar'); + $route->setHost('en.example.com'); + $route->setCondition("params['_route'] matches '/^s[a-z\-]+$/'"); + $coll->add('static-with-host', $route); + $route = new Route('/foo/{id}'); + $route->setCondition("params['id'] < 100"); + $coll->add('dynamic1', $route); + $route = new Route('/foo/{id}'); + $route->setCondition("params['id'] > 100 and params['id'] < 1000"); + $coll->add('dynamic2', $route); + $route = new Route('/bar/{id}/'); + $route->setCondition("params['id'] < 100"); + $coll->add('dynamic-with-slash', $route); + $matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php', 'GET', 'en.example.com')); + + $this->assertEquals(['_route' => 'static'], $matcher->match('/foo')); + $this->assertEquals(['_route' => 'static-with-host'], $matcher->match('/bar')); + $this->assertEquals(['_route' => 'dynamic1', 'id' => '10'], $matcher->match('/foo/10')); + $this->assertEquals(['_route' => 'dynamic2', 'id' => '200'], $matcher->match('/foo/200')); + $this->assertEquals(['_route' => 'dynamic-with-slash', 'id' => '10'], $matcher->match('/bar/10/')); + + $this->expectException(ResourceNotFoundException::class); + $matcher->match('/foo/3000'); + } + public function testDecodeOnce() { $coll = new RouteCollection(); From c93d3dd1a5b52a5f521ebc066e872f02a422e609 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 19 Apr 2022 12:12:13 +0200 Subject: [PATCH 29/60] Indicate support for doctrine/persistence 3 --- composer.json | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Component/Messenger/composer.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 85fd3e01a285..25674294d079 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-xml": "*", "friendsofphp/proxy-manager-lts": "^1.0.2", "doctrine/event-manager": "~1.0", - "doctrine/persistence": "^1.3|^2", + "doctrine/persistence": "^1.3|^2|^3", "twig/twig": "^1.43|^2.13|^3.0.4", "psr/cache": "^1.0|^2.0", "psr/container": "^1.0", diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index cce2609cf1a8..f14aa99bc8ad 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.1.3", "doctrine/event-manager": "~1.0", - "doctrine/persistence": "^1.3|^2", + "doctrine/persistence": "^1.3|^2|^3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php80": "^1.16", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 1e382f1dcf0c..a9735e6c47ec 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -33,7 +33,7 @@ "require-dev": { "doctrine/annotations": "^1.10.4", "doctrine/cache": "^1.0|^2.0", - "doctrine/persistence": "^1.3|^2.0", + "doctrine/persistence": "^1.3|^2|^3", "paragonie/sodium_compat": "^1.8", "symfony/asset": "^3.4|^4.0|^5.0", "symfony/browser-kit": "^4.3|^5.0", diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index 9481665039e0..fd8aabb747cb 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "doctrine/dbal": "^2.6|^3.0", - "doctrine/persistence": "^1.3|^2", + "doctrine/persistence": "^1.3|^2|^3", "psr/cache": "^1.0|^2.0|^3.0", "symfony/console": "^3.4|^4.0|^5.0", "symfony/dependency-injection": "^3.4.19|^4.1.8|^5.0", From a1c92c722e5b1d0460b733d7b6d36fd2ced19fb4 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 19 Apr 2022 12:40:37 +0200 Subject: [PATCH 30/60] [String] Fix ansi escape sequences regex --- src/Symfony/Component/String/AbstractUnicodeString.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index db810cb6ddcd..767f62320cd1 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -492,7 +492,7 @@ public function width(bool $ignoreAnsiDecoration = true): int foreach (explode("\n", $s) as $s) { if ($ignoreAnsiDecoration) { $s = preg_replace('/(?:\x1B(?: - \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [0x40-\x7E] + \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E] | [P\]X^_] .*? \x1B\\\\ | [\x41-\x7E] )|[\p{Cc}\x7F]++)/xu', '', $s); From 692e277ab58266cfb201f17ca5c00d1aba76012e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 19 Apr 2022 11:16:05 +0200 Subject: [PATCH 31/60] [Notifier] [Smsapi] Show `test` and `fast` in DSN only when `true` --- .../Bridge/Smsapi/SmsapiTransport.php | 12 +++++- .../Bridge/Smsapi/SmsapiTransportFactory.php | 6 +-- .../Tests/SmsapiTransportFactoryTest.php | 38 ++++++++++++++----- .../Smsapi/Tests/SmsapiTransportTest.php | 9 +++-- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php index 3f6fdc214a7e..2b745c4b7729 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php @@ -64,7 +64,17 @@ public function setTest(bool $test): static public function __toString(): string { - return sprintf('smsapi://%s?from=%s&fast=%d', $this->getEndpoint(), $this->from, (int) $this->fast); + $dsn = sprintf('smsapi://%s?from=%s', $this->getEndpoint(), $this->from); + + if ($this->fast) { + $dsn .= sprintf('&fast=%d', (int) $this->fast); + } + + if ($this->test) { + $dsn .= sprintf('&test=%d', (int) $this->test); + } + + return $dsn; } public function supports(MessageInterface $message): bool diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php index 75caaffb24e8..3f498ab8edf2 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php @@ -35,11 +35,7 @@ public function create(Dsn $dsn): SmsapiTransport $test = filter_var($dsn->getOption('test', false), \FILTER_VALIDATE_BOOLEAN); $port = $dsn->getPort(); - return (new SmsapiTransport($authToken, $from, $this->client, $this->dispatcher)) - ->setFast($fast) - ->setHost($host) - ->setPort($port) - ->setTest($test); + return (new SmsapiTransport($authToken, $from, $this->client, $this->dispatcher))->setFast($fast)->setHost($host)->setPort($port)->setTest($test); } protected function getSupportedSchemes(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php index 098af9af69c8..264c0d7ec9fb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php @@ -24,30 +24,48 @@ public function createFactory(): SmsapiTransportFactory public function createProvider(): iterable { yield [ - 'smsapi://host.test?from=testFrom&fast=0', + 'smsapi://host.test?from=testFrom', 'smsapi://token@host.test?from=testFrom', - 'smsapi://token@host.test?from=testFrom&fast=0&test=0', ]; yield [ - 'smsapi://host.test?from=testFrom&fast=0', - 'smsapi://token@host.test?from=testFrom&fast=0', - 'smsapi://token@host.test?from=testFrom&fast=1&test=0', + 'smsapi://host.test?from=testFrom', 'smsapi://token@host.test?from=testFrom&test=0', ]; + yield [ + 'smsapi://host.test?from=testFrom', + 'smsapi://token@host.test?from=testFrom&fast=0', + ]; + + yield [ + 'smsapi://host.test?from=testFrom', + 'smsapi://token@host.test?from=testFrom&test=false', + ]; + + yield [ + 'smsapi://host.test?from=testFrom', + 'smsapi://token@host.test?from=testFrom&fast=false', + ]; + + yield [ + 'smsapi://host.test?from=testFrom&test=1', + 'smsapi://token@host.test?from=testFrom&test=1', + ]; + yield [ 'smsapi://host.test?from=testFrom&fast=1', 'smsapi://token@host.test?from=testFrom&fast=1', - 'smsapi://token@host.test?from=testFrom&fast=1&test=1', - 'smsapi://token@host.test?from=testFrom&test=1', + ]; + + yield [ + 'smsapi://host.test?from=testFrom&test=1', + 'smsapi://token@host.test?from=testFrom&test=true', ]; yield [ 'smsapi://host.test?from=testFrom&fast=1', 'smsapi://token@host.test?from=testFrom&fast=true', - 'smsapi://token@host.test?from=testFrom&fast=true&test=true', - 'smsapi://token@host.test?from=testFrom&test=true', ]; } @@ -55,7 +73,7 @@ public function supportsProvider(): iterable { yield [true, 'smsapi://host?from=testFrom']; yield [true, 'smsapi://host?from=testFrom&fast=1']; - yield [true, 'smsapi://host?from=testFrom&fast=1&test=1']; + yield [true, 'smsapi://host?from=testFrom&test=1']; yield [false, 'somethingElse://host?from=testFrom']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php index e8eb203792c6..73213d8907a0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php @@ -23,14 +23,17 @@ final class SmsapiTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null): SmsapiTransport + public function createTransport(HttpClientInterface $client = null, bool $fast = false, bool $test = false): SmsapiTransport { - return (new SmsapiTransport('testToken', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setFast(true)->setHost('test.host')->setTest(true); + return (new SmsapiTransport('testToken', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('test.host')->setFast($fast)->setTest($test); } public function toStringProvider(): iterable { - yield ['smsapi://test.host?from=testFrom&fast=1', $this->createTransport()]; + yield ['smsapi://test.host?from=testFrom', $this->createTransport()]; + yield ['smsapi://test.host?from=testFrom&fast=1', $this->createTransport(null, true)]; + yield ['smsapi://test.host?from=testFrom&test=1', $this->createTransport(null, false, true)]; + yield ['smsapi://test.host?from=testFrom&fast=1&test=1', $this->createTransport(null, true, true)]; } public function supportedMessagesProvider(): iterable From d8a46808370937eda0205008ddcbad172514e070 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Wed, 23 Mar 2022 17:52:31 +0100 Subject: [PATCH 32/60] [DependencyInjection] add AsDecorator class attribute and InnerService parameter attribute --- .../Attribute/AsDecorator.php | 25 ++++++++++ .../Attribute/InnerService.php | 17 +++++++ .../Compiler/AutowireAsDecoratorPass.php | 49 +++++++++++++++++++ .../Compiler/AutowirePass.php | 7 +++ .../Compiler/PassConfig.php | 1 + .../Tests/Compiler/AutowirePassTest.php | 22 +++++++++ .../includes/autowiring_classes_80.php | 35 +++++++++++++ 7 files changed, 156 insertions(+) create mode 100644 src/Symfony/Component/DependencyInjection/Attribute/AsDecorator.php create mode 100644 src/Symfony/Component/DependencyInjection/Attribute/InnerService.php create mode 100644 src/Symfony/Component/DependencyInjection/Compiler/AutowireAsDecoratorPass.php diff --git a/src/Symfony/Component/DependencyInjection/Attribute/AsDecorator.php b/src/Symfony/Component/DependencyInjection/Attribute/AsDecorator.php new file mode 100644 index 000000000000..0f80c16e974d --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Attribute/AsDecorator.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Attribute; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +#[\Attribute(\Attribute::TARGET_CLASS)] +class AsDecorator +{ + public function __construct( + public string $decorates, + public int $priority = 0, + public int $onInvalid = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, + ) { + } +} diff --git a/src/Symfony/Component/DependencyInjection/Attribute/InnerService.php b/src/Symfony/Component/DependencyInjection/Attribute/InnerService.php new file mode 100644 index 000000000000..46e987e43518 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Attribute/InnerService.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Attribute; + +#[\Attribute(\Attribute::TARGET_PARAMETER)] +class InnerService +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowireAsDecoratorPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowireAsDecoratorPass.php new file mode 100644 index 000000000000..66eed9a37fa7 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowireAsDecoratorPass.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Attribute\AsDecorator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Reads #[AsDecorator] attributes on definitions that are autowired + * and don't have the "container.ignore_attributes" tag. + */ +final class AutowireAsDecoratorPass implements CompilerPassInterface +{ + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container) + { + foreach ($container->getDefinitions() as $definition) { + if ($this->accept($definition) && $reflectionClass = $container->getReflectionClass($definition->getClass(), false)) { + $this->processClass($definition, $reflectionClass); + } + } + } + + private function accept(Definition $definition): bool + { + return !$definition->hasTag('container.ignore_attributes') && $definition->isAutowired(); + } + + private function processClass(Definition $definition, \ReflectionClass $reflectionClass) + { + foreach ($reflectionClass->getAttributes(AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { + $attribute = $attribute->newInstance(); + + $definition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid); + } + } +} diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 25fa2cfa584f..a47b6ba69be1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\Attribute\Autowire; +use Symfony\Component\DependencyInjection\Attribute\InnerService; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; use Symfony\Component\DependencyInjection\Attribute\TaggedLocator; use Symfony\Component\DependencyInjection\Attribute\Target; @@ -271,6 +272,12 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a break; } + + if (InnerService::class === $attribute->getName()) { + $arguments[$index] = new Reference($this->currentId.'.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE); + + break; + } } if ('' !== ($arguments[$index] ?? '')) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index 437383318031..3acbe26de0d3 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -43,6 +43,7 @@ public function __construct() 100 => [ new ResolveClassPass(), new RegisterAutoconfigureAttributesPass(), + new AutowireAsDecoratorPass(), new AttributeAutoconfigurationPass(), new ResolveInstanceofConditionalsPass(), new RegisterEnvVarProcessorsPass(), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 10a7eed918e8..c9422d98b26e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Compiler\AutowireAsDecoratorPass; use Symfony\Component\DependencyInjection\Compiler\AutowirePass; use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass; use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass; @@ -1164,4 +1165,25 @@ public function testAutowireAttribute() $this->assertSame('@bar', $service->escapedRawValue); $this->assertNull($service->invalid); } + + public function testAsDecoratorAttribute() + { + $container = new ContainerBuilder(); + + $container->register(AsDecoratorFoo::class); + $container->register(AsDecoratorBar10::class)->setAutowired(true)->setArgument(0, 'arg1'); + $container->register(AsDecoratorBar20::class)->setAutowired(true)->setArgument(0, 'arg1'); + $container->register(AsDecoratorBaz::class)->setAutowired(true); + + (new ResolveClassPass())->process($container); + (new AutowireAsDecoratorPass())->process($container); + (new DecoratorServicePass())->process($container); + (new AutowirePass())->process($container); + + $this->assertSame(AsDecoratorBar10::class.'.inner', (string) $container->getDefinition(AsDecoratorBar10::class)->getArgument(1)); + + $this->assertSame(AsDecoratorBar20::class.'.inner', (string) $container->getDefinition(AsDecoratorBar20::class)->getArgument(1)); + $this->assertSame(AsDecoratorBaz::class.'.inner', (string) $container->getDefinition(AsDecoratorBaz::class)->getArgument(0)); + $this->assertSame(2, $container->getDefinition(AsDecoratorBaz::class)->getArgument(0)->getInvalidBehavior()); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php index 80c3251fa75d..de2583d3b2ed 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php @@ -2,7 +2,10 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use Symfony\Component\DependencyInjection\Attribute\AsDecorator; use Symfony\Component\DependencyInjection\Attribute\Autowire; +use Symfony\Component\DependencyInjection\Attribute\InnerService; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Contracts\Service\Attribute\Required; class AutowireSetter @@ -50,3 +53,35 @@ public function __construct( ) { } } + +interface AsDecoratorInterface +{ +} + +class AsDecoratorFoo implements AsDecoratorInterface +{ +} + +#[AsDecorator(decorates: AsDecoratorFoo::class, priority: 10)] +class AsDecoratorBar10 implements AsDecoratorInterface +{ + public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner) + { + } +} + +#[AsDecorator(decorates: AsDecoratorFoo::class, priority: 20)] +class AsDecoratorBar20 implements AsDecoratorInterface +{ + public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner) + { + } +} + +#[AsDecorator(decorates: \NonExistent::class, onInvalid: ContainerInterface::NULL_ON_INVALID_REFERENCE)] +class AsDecoratorBaz implements AsDecoratorInterface +{ + public function __construct(#[InnerService] AsDecoratorInterface $inner = null) + { + } +} From c0a7979055cabc715c142df13c5bc34d0af6a418 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Tue, 19 Apr 2022 16:47:41 +0200 Subject: [PATCH 33/60] [DependencyInjection] Rename `#[InnerService]` to `#[MapDecorated]` --- .../Attribute/{InnerService.php => MapDecorated.php} | 2 +- src/Symfony/Component/DependencyInjection/CHANGELOG.md | 2 ++ .../DependencyInjection/Compiler/AutowirePass.php | 7 ++++--- .../Tests/Fixtures/includes/autowiring_classes_80.php | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) rename src/Symfony/Component/DependencyInjection/Attribute/{InnerService.php => MapDecorated.php} (94%) diff --git a/src/Symfony/Component/DependencyInjection/Attribute/InnerService.php b/src/Symfony/Component/DependencyInjection/Attribute/MapDecorated.php similarity index 94% rename from src/Symfony/Component/DependencyInjection/Attribute/InnerService.php rename to src/Symfony/Component/DependencyInjection/Attribute/MapDecorated.php index 46e987e43518..4fbbf68c6249 100644 --- a/src/Symfony/Component/DependencyInjection/Attribute/InnerService.php +++ b/src/Symfony/Component/DependencyInjection/Attribute/MapDecorated.php @@ -12,6 +12,6 @@ namespace Symfony\Component\DependencyInjection\Attribute; #[\Attribute(\Attribute::TARGET_PARAMETER)] -class InnerService +class MapDecorated { } diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index 0bb0d6a7063d..ced60bd357c4 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -4,6 +4,8 @@ CHANGELOG 6.1 --- + * Add `#[MapDecorated]` attribute telling to which parameter the decorated service should be mapped in a decorator + * Add `#[AsDecorator]` attribute to make a service decorates another * Add `$exclude` to `TaggedIterator` and `TaggedLocator` attributes * Add `$exclude` to `tagged_iterator` and `tagged_locator` configurator * Add an `env` function to the expression language provider diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index a47b6ba69be1..b8634eafe4a4 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\Attribute\Autowire; -use Symfony\Component\DependencyInjection\Attribute\InnerService; +use Symfony\Component\DependencyInjection\Attribute\MapDecorated; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; use Symfony\Component\DependencyInjection\Attribute\TaggedLocator; use Symfony\Component\DependencyInjection\Attribute\Target; @@ -273,8 +273,9 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a break; } - if (InnerService::class === $attribute->getName()) { - $arguments[$index] = new Reference($this->currentId.'.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE); + if (MapDecorated::class === $attribute->getName()) { + $definition = $this->container->getDefinition($this->currentId); + $arguments[$index] = new Reference($definition->innerServiceId ?? $this->currentId.'.inner', $definition->decorationOnInvalid ?? ContainerInterface::NULL_ON_INVALID_REFERENCE); break; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php index de2583d3b2ed..c1c772b684a4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php @@ -4,7 +4,7 @@ use Symfony\Component\DependencyInjection\Attribute\AsDecorator; use Symfony\Component\DependencyInjection\Attribute\Autowire; -use Symfony\Component\DependencyInjection\Attribute\InnerService; +use Symfony\Component\DependencyInjection\Attribute\MapDecorated; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Contracts\Service\Attribute\Required; @@ -65,7 +65,7 @@ class AsDecoratorFoo implements AsDecoratorInterface #[AsDecorator(decorates: AsDecoratorFoo::class, priority: 10)] class AsDecoratorBar10 implements AsDecoratorInterface { - public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner) + public function __construct(string $arg1, #[MapDecorated] AsDecoratorInterface $inner) { } } @@ -73,7 +73,7 @@ public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $ #[AsDecorator(decorates: AsDecoratorFoo::class, priority: 20)] class AsDecoratorBar20 implements AsDecoratorInterface { - public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner) + public function __construct(string $arg1, #[MapDecorated] AsDecoratorInterface $inner) { } } @@ -81,7 +81,7 @@ public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $ #[AsDecorator(decorates: \NonExistent::class, onInvalid: ContainerInterface::NULL_ON_INVALID_REFERENCE)] class AsDecoratorBaz implements AsDecoratorInterface { - public function __construct(#[InnerService] AsDecoratorInterface $inner = null) + public function __construct(#[MapDecorated] AsDecoratorInterface $inner = null) { } } From 2daae4655ca88723a087a64340f40b79f24a76e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 20 Apr 2022 08:22:07 +0200 Subject: [PATCH 34/60] Add missing return type to HttpClient --- src/Symfony/Component/HttpClient/Response/AmpResponse.php | 6 +++--- src/Symfony/Component/HttpClient/Response/MockResponse.php | 4 ++-- src/Symfony/Component/HttpClient/Response/StreamWrapper.php | 2 +- .../Component/HttpClient/Response/TraceableResponse.php | 2 +- .../HttpClient/Response/TransportResponseTrait.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/AmpResponse.php b/src/Symfony/Component/HttpClient/Response/AmpResponse.php index b8dff00a551b..7ab4ec5c11c9 100644 --- a/src/Symfony/Component/HttpClient/Response/AmpResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AmpResponse.php @@ -226,7 +226,7 @@ private static function select(ClientState $multi, float $timeout): int return null === self::$delay ? 1 : 0; } - private static function generateResponse(Request $request, AmpClientState $multi, string $id, array &$info, array &$headers, CancellationTokenSource $canceller, array &$options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, Promise &$pause) + private static function generateResponse(Request $request, AmpClientState $multi, string $id, array &$info, array &$headers, CancellationTokenSource $canceller, array &$options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, Promise &$pause): \Generator { $request->setInformationalResponseHandler(static function (Response $response) use ($multi, $id, &$info, &$headers) { self::addResponseHeaders($response, $info, $headers); @@ -285,7 +285,7 @@ private static function generateResponse(Request $request, AmpClientState $multi self::stopLoop(); } - private static function followRedirects(Request $originRequest, AmpClientState $multi, array &$info, array &$headers, CancellationTokenSource $canceller, array $options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, Promise &$pause) + private static function followRedirects(Request $originRequest, AmpClientState $multi, array &$info, array &$headers, CancellationTokenSource $canceller, array $options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, Promise &$pause): \Generator { yield $pause; @@ -399,7 +399,7 @@ private static function addResponseHeaders(Response $response, array &$info, arr /** * Accepts pushed responses only if their headers related to authentication match the request. */ - private static function getPushedResponse(Request $request, AmpClientState $multi, array &$info, array &$headers, array $options, ?LoggerInterface $logger) + private static function getPushedResponse(Request $request, AmpClientState $multi, array &$info, array &$headers, array $options, ?LoggerInterface $logger): \Generator { if ('' !== $options['body']) { return null; diff --git a/src/Symfony/Component/HttpClient/Response/MockResponse.php b/src/Symfony/Component/HttpClient/Response/MockResponse.php index d143de2aa006..9b80f310e8f1 100644 --- a/src/Symfony/Component/HttpClient/Response/MockResponse.php +++ b/src/Symfony/Component/HttpClient/Response/MockResponse.php @@ -229,7 +229,7 @@ protected static function select(ClientState $multi, float $timeout): int /** * Simulates sending the request. */ - private static function writeRequest(self $response, array $options, ResponseInterface $mock) + private static function writeRequest(self $response, array $options, ResponseInterface $mock): void { $onProgress = $options['on_progress'] ?? static function () {}; $response->info += $mock->getInfo() ?: []; @@ -272,7 +272,7 @@ private static function writeRequest(self $response, array $options, ResponseInt /** * Simulates reading the response. */ - private static function readResponse(self $response, array $options, ResponseInterface $mock, int &$offset) + private static function readResponse(self $response, array $options, ResponseInterface $mock, int &$offset): void { $onProgress = $options['on_progress'] ?? static function () {}; diff --git a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php index 9879c78d26ac..e002a004816d 100644 --- a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php +++ b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php @@ -117,7 +117,7 @@ public function stream_open(string $path, string $mode, int $options): bool return false; } - public function stream_read(int $count) + public function stream_read(int $count): string|false { if (\is_resource($this->content)) { // Empty the internal activity list diff --git a/src/Symfony/Component/HttpClient/Response/TraceableResponse.php b/src/Symfony/Component/HttpClient/Response/TraceableResponse.php index 4d665f4d8c7f..507799e1428a 100644 --- a/src/Symfony/Component/HttpClient/Response/TraceableResponse.php +++ b/src/Symfony/Component/HttpClient/Response/TraceableResponse.php @@ -202,7 +202,7 @@ public static function stream(HttpClientInterface $client, iterable $responses, } } - private function checkStatusCode(int $code) + private function checkStatusCode(int $code): void { if (500 <= $code) { throw new ServerException($this); diff --git a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php index c639eb9fcd1c..f2615111bc97 100644 --- a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php @@ -131,7 +131,7 @@ private static function addResponseHeaders(array $responseHeaders, array &$info, /** * Ensures the request is always sent and that the response code was checked. */ - private function doDestruct() + private function doDestruct(): void { $this->shouldBuffer = true; From 3ae3e5a0a2741011cbf566781a3a374f0cd466c4 Mon Sep 17 00:00:00 2001 From: Robert-Jan de Dreu Date: Wed, 20 Apr 2022 15:17:46 +0200 Subject: [PATCH 35/60] Fix "Notice: Undefined index: headers" in messenger with Oracle --- .../Messenger/Tests/Transport/Doctrine/ConnectionTest.php | 2 +- .../Component/Messenger/Transport/Doctrine/Connection.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php index dc420e79bb24..98a7aec31bd6 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php @@ -409,7 +409,7 @@ public function providePlatformSql(): iterable yield 'Oracle' => [ new OraclePlatform(), - 'SELECT w.* FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE', + 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE', ]; } } diff --git a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php index 379132c9c98d..c00e8f86d3b1 100644 --- a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php @@ -193,7 +193,11 @@ public function get(): ?array $sql = str_replace('SELECT a.* FROM', 'SELECT a.id FROM', $sql); $wrappedQuery = $this->driverConnection->createQueryBuilder() - ->select('w.*') + ->select( + 'w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", '. + 'w.created_at AS "created_at", w.available_at AS "available_at", '. + 'w.delivered_at AS "delivered_at"' + ) ->from($this->configuration['table_name'], 'w') ->where('w.id IN('.$sql.')'); From 0ae445cb09ee9375508e9b404f33c7c7354a358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 20 Apr 2022 00:29:42 +0200 Subject: [PATCH 36/60] [FrameworkBundle] Add support for route attributes in kernel controller methods --- src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../FrameworkBundle/Kernel/MicroKernelTrait.php | 4 ++++ .../Tests/Kernel/MicroKernelTraitTest.php | 5 +++++ .../Kernel/flex-style/src/FlexStyleMicroKernel.php | 13 ++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index f13c4790988d..1751a123bba5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG * Add `trust_x_sendfile_type_header` option * Add support for first-class callable route controller in `MicroKernelTrait` * Add tag `routing.condition_service` to autoconfigure routing condition services + * Automatically register kernel methods marked with the `Symfony\Component\Routing\Annotation\Route` attribute or annotation as controllers in `MicroKernelTrait` 6.0 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index dbf818f13a65..dbf77b3bd94b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -82,6 +82,10 @@ private function configureRoutes(RoutingConfigurator $routes): void } else { $routes->import($configDir.'/{routes}.php'); } + + if (false !== ($fileName = (new \ReflectionObject($this))->getFileName())) { + $routes->import($fileName, 'annotation'); + } } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index 2a3cebb7fdf1..fff93fc65a8e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -94,6 +94,11 @@ public function testFlexStyle() $response = $kernel->handle($request); $this->assertEquals('Have a great day!', $response->getContent()); + + $request = Request::create('/easter'); + $response = $kernel->handle($request); + + $this->assertSame('easter', $response->getContent()); } public function testSecretLoadedFromExtension() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php index ecc693367d54..122f73cd4ead 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php @@ -18,11 +18,14 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class FlexStyleMicroKernel extends Kernel { - use MicroKernelTrait; + use MicroKernelTrait { + configureRoutes as traitConfigureRoutes; + } private $cacheDir; @@ -31,6 +34,12 @@ public function halloweenAction(\stdClass $o) return new Response($o->halloween); } + #[Route('/easter')] + public function easterAction() + { + return new Response('easter'); + } + public function createHalloween(LoggerInterface $logger, string $halloween) { $o = new \stdClass(); @@ -73,6 +82,8 @@ public function __destruct() protected function configureRoutes(RoutingConfigurator $routes): void { + $this->traitConfigureRoutes($routes); + $routes->add('halloween', '/')->controller([$this, 'halloweenAction']); $routes->add('halloween2', '/h')->controller($this->halloweenAction(...)); } From 3fab417fc7e7f3d25f87bcf9936b770ffdae6838 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 20 Apr 2022 16:19:47 +0200 Subject: [PATCH 37/60] [FrameworkBundle] Always add CacheCollectorPass --- src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index f5c52cf19749..1e76d527cd6b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -157,12 +157,12 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new RegisterReverseContainerPass(true)); $container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new SessionPass()); + $container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2); $container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255); - $container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING); } } From cf4daad6b7f81f1118ffb98c5467904d402a65b9 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 20 Apr 2022 17:01:42 +0200 Subject: [PATCH 38/60] Minor @requires function tests cleanup --- .../Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php | 3 --- .../Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php | 3 --- .../Tests/Routing/RedirectableCompiledUrlMatcherTest.php | 3 --- .../Cache/Tests/Messenger/EarlyExpirationDispatcherTest.php | 3 --- .../Cache/Tests/Messenger/EarlyExpirationHandlerTest.php | 3 --- .../Cache/Tests/Messenger/EarlyExpirationMessageTest.php | 3 --- .../Component/Console/Tests/Helper/QuestionHelperTest.php | 3 --- .../ChoiceList/Factory/DefaultChoiceListFactoryTest.php | 3 --- .../Component/PropertyAccess/Tests/PropertyAccessorTest.php | 3 --- .../VarDumper/Tests/Caster/ExceptionCasterTest.php | 3 --- .../Component/VarDumper/Tests/Dumper/CliDumperTest.php | 3 --- .../Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php | 6 ------ 12 files changed, 39 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php b/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php index 957ac0f60aeb..0c6968bf0470 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php @@ -29,9 +29,6 @@ public function testUlidCanBeGenerated() $this->assertTrue(Ulid::isValid($ulid)); } - /** - * @requires function \Symfony\Component\Uid\Factory\UlidFactory::create - */ public function testUlidFactory() { $ulid = new Ulid('00000000000000000000000000'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php b/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php index 34367b0bd721..9b667e942366 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php @@ -18,9 +18,6 @@ use Symfony\Component\Uid\UuidV4; use Symfony\Component\Uid\UuidV6; -/** - * @requires function \Symfony\Component\Uid\Factory\UuidFactory::create - */ class UuidGeneratorTest extends TestCase { public function testUuidCanBeGenerated() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableCompiledUrlMatcherTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableCompiledUrlMatcherTest.php index bf61409d4ee2..29126e130b56 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableCompiledUrlMatcherTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableCompiledUrlMatcherTest.php @@ -18,9 +18,6 @@ use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -/** - * @requires function \Symfony\Component\Routing\Matcher\CompiledUrlMatcher::match - */ class RedirectableCompiledUrlMatcherTest extends TestCase { public function testRedirectWhenNoSlash() diff --git a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationDispatcherTest.php b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationDispatcherTest.php index 7d5d89aa9c36..a471cc18d104 100644 --- a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationDispatcherTest.php +++ b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationDispatcherTest.php @@ -26,9 +26,6 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\MessageBusInterface; -/** - * @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct - */ class EarlyExpirationDispatcherTest extends TestCase { public static function tearDownAfterClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php index f42bca5525af..44ec8a473340 100644 --- a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php +++ b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php @@ -21,9 +21,6 @@ use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\Filesystem\Filesystem; -/** - * @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct - */ class EarlyExpirationHandlerTest extends TestCase { public static function tearDownAfterClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationMessageTest.php b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationMessageTest.php index 038357a49971..9d8a643d65b1 100644 --- a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationMessageTest.php +++ b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationMessageTest.php @@ -19,9 +19,6 @@ use Symfony\Component\DependencyInjection\ReverseContainer; use Symfony\Component\DependencyInjection\ServiceLocator; -/** - * @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct - */ class EarlyExpirationMessageTest extends TestCase { public function testCreate() diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 1297b92f98a8..95ab1b30270d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -714,9 +714,6 @@ public function testNoInteraction() $this->assertEquals('not yet', $dialog->ask($this->createStreamableInputInterfaceMock(null, false), $this->createOutputInterface(), $question)); } - /** - * @requires function mb_strwidth - */ public function testChoiceOutputFormattingQuestionForUtf8Keys() { $question = 'Lorem ipsum?'; diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 0fa93ba32db5..f3c790aa0c5e 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -759,9 +759,6 @@ function ($object, $key, $value) { $this->assertFlatViewWithAttr($view); } - /** - * @requires function Symfony\Component\Translation\TranslatableMessage::__construct - */ public function testPassTranslatableMessageAsLabelDoesntCastItToString() { $view = $this->factory->createView( diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 972d169caa83..52bc468e6732 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -907,9 +907,6 @@ public function testGetDynamicPublicPropertyWithMagicGetterAllow() $this->assertSame($value, $this->propertyAccessor->getValue($object, $path)); } - /** - * @requires PHP 7.4 - */ public function testSetValueWrongTypeShouldThrowWrappedException() { $object = new TestClassTypedProperty(); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php index 915588c0009e..895cd57fe582 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php @@ -184,9 +184,6 @@ public function testHtmlDump() $this->assertStringMatchesFormat($expectedDump, $dump); } - /** - * @requires function Twig\Template::getSourceContext - */ public function testFrameWithTwig() { require_once \dirname(__DIR__).'/Fixtures/Twig.php'; diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index b2f4733081c2..44cb49de01ed 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -293,9 +293,6 @@ public function testFlags() putenv('DUMP_STRING_LENGTH='); } - /** - * @requires function Twig\Template::getSourceContext - */ public function testThrowingCaster() { $out = fopen('php://memory', 'r+'); diff --git a/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php b/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php index 0bea476e10d6..4691e119cf9e 100644 --- a/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php +++ b/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php @@ -87,9 +87,6 @@ public function testGetMarkingWithValueObject() $this->assertSame('first_place', (string) $subject->getMarking()); } - /** - * @requires PHP 7.4 - */ public function testGetMarkingWithUninitializedProperty() { $subject = new SubjectWithType(); @@ -102,9 +99,6 @@ public function testGetMarkingWithUninitializedProperty() $this->assertCount(0, $marking->getPlaces()); } - /** - * @requires PHP 7.4 - */ public function testGetMarkingWithUninitializedProperty2() { $subject = new SubjectWithType(); From 9d35f006a4dd1fef3be5eef1386ebd1a4ea18b20 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 20 Apr 2022 17:33:57 +0200 Subject: [PATCH 39/60] [SecurityBundle] Remove forgotten unused code --- .../Security/Factory/RememberMeFactory.php | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index 6acbfa4c6334..1209041001ab 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -16,7 +16,6 @@ use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -194,54 +193,6 @@ public function addConfiguration(NodeDefinition $node) } } - private function generateRememberMeServicesTemplateId(array $config, string $id): string - { - if (isset($config['service'])) { - return $config['service']; - } - - if (isset($config['token_provider'])) { - return 'security.authentication.rememberme.services.persistent'; - } - - return 'security.authentication.rememberme.services.simplehash'; - } - - private function createRememberMeServices(ContainerBuilder $container, string $id, string $templateId, array $userProviders, array $config): void - { - $rememberMeServicesId = $templateId.'.'.$id; - - $rememberMeServices = $container->setDefinition($rememberMeServicesId, new ChildDefinition($templateId)); - $rememberMeServices->replaceArgument(1, $config['secret']); - $rememberMeServices->replaceArgument(2, $id); - - if (isset($config['token_provider'])) { - $tokenProviderId = $this->createTokenProvider($container, $id, $config['token_provider']); - $rememberMeServices->addMethodCall('setTokenProvider', [new Reference($tokenProviderId)]); - } - - // remember-me options - $mergedOptions = array_intersect_key($config, $this->options); - if ('auto' === $mergedOptions['secure']) { - $mergedOptions['secure'] = null; - } - - $rememberMeServices->replaceArgument(3, $mergedOptions); - - if ($config['user_providers']) { - $userProviders = []; - foreach ($config['user_providers'] as $providerName) { - $userProviders[] = new Reference('security.user.provider.concrete.'.$providerName); - } - } - - if (0 === \count($userProviders)) { - throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.'); - } - - $rememberMeServices->replaceArgument(0, new IteratorArgument(array_unique($userProviders))); - } - private function createTokenProvider(ContainerBuilder $container, string $firewallName, array $config): string { $tokenProviderId = $config['service'] ?? false; From 4d5528326ebe785c5fe78ea03b03723ae094159e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Apr 2022 08:07:10 +0200 Subject: [PATCH 40/60] Fix typo --- src/Symfony/Component/Routing/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 8d6f80a15299..21371e710b0b 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -5,7 +5,7 @@ CHANGELOG --- * Add `params` variable to condition expression - * Deprecate not passing route parameters as the forth argument to `UrlMatcher::handleRouteRequirements()` + * Deprecate not passing route parameters as the fourth argument to `UrlMatcher::handleRouteRequirements()` 6.1 --- From f9cf24a1cbc93d7530a01753a5882757318b79b7 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Mon, 11 Apr 2022 03:15:21 +0200 Subject: [PATCH 41/60] [FrameworkBundle] deprecate not setting http_method_override --- UPGRADE-6.1.md | 1 + .../Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../DependencyInjection/Configuration.php | 15 +++++++++++++-- .../AboutCommand/Fixture/TestAppKernel.php | 5 +++++ .../CacheClearCommand/Fixture/config.yml | 1 + .../DependencyInjection/ConfigurationTest.php | 18 ++++++++++++++---- .../Fixtures/php/assets.php | 1 + .../Fixtures/php/assets_disabled.php | 1 + .../php/assets_version_strategy_as_service.php | 1 + .../DependencyInjection/Fixtures/php/cache.php | 1 + .../Fixtures/php/cache_app_redis_tag_aware.php | 1 + .../php/cache_app_redis_tag_aware_pool.php | 1 + .../DependencyInjection/Fixtures/php/csrf.php | 1 + .../Fixtures/php/csrf_needs_session.php | 1 + .../Fixtures/php/default_config.php | 3 ++- .../php/esi_and_ssi_without_fragments.php | 1 + .../Fixtures/php/esi_disabled.php | 1 + .../Fixtures/php/exceptions.php | 1 + .../Fixtures/php/form_default_csrf.php | 1 + .../Fixtures/php/form_no_csrf.php | 1 + .../Fixtures/php/fragments_and_hinclude.php | 1 + .../Fixtures/php/html_sanitizer.php | 1 + .../php/http_client_default_options.php | 1 + .../php/http_client_full_default_options.php | 1 + .../php/http_client_mock_response_factory.php | 1 + .../http_client_override_default_options.php | 1 + .../Fixtures/php/http_client_retry.php | 1 + ...http_client_scoped_without_query_option.php | 1 + .../Fixtures/php/http_client_xml_key.php | 1 + .../php/legacy_translator_enabled_locales.php | 1 + .../Fixtures/php/mailer.php | 1 + .../php/mailer_with_disabled_message_bus.php | 1 + .../Fixtures/php/mailer_with_dsn.php | 1 + .../php/mailer_with_specific_message_bus.php | 1 + .../Fixtures/php/mailer_with_transports.php | 1 + .../Fixtures/php/messenger.php | 1 + .../Fixtures/php/messenger_disabled.php | 1 + ...ger_middleware_factory_erroneous_format.php | 1 + .../Fixtures/php/messenger_multiple_buses.php | 1 + .../messenger_multiple_failure_transports.php | 1 + ...nger_multiple_failure_transports_global.php | 1 + .../Fixtures/php/messenger_routing.php | 1 + .../messenger_routing_invalid_transport.php | 1 + .../Fixtures/php/messenger_routing_single.php | 1 + .../Fixtures/php/messenger_transport.php | 1 + .../Fixtures/php/messenger_transports.php | 1 + ...essenger_with_disabled_reset_on_message.php | 1 + ...er_with_explict_reset_on_message_legacy.php | 1 + .../Fixtures/php/notifier.php | 1 + .../Fixtures/php/notifier_without_mailer.php | 1 + .../php/notifier_without_messenger.php | 1 + .../php/notifier_without_transports.php | 1 + .../Fixtures/php/php_errors_disabled.php | 1 + .../Fixtures/php/php_errors_enabled.php | 1 + .../Fixtures/php/php_errors_log_level.php | 1 + .../Fixtures/php/php_errors_log_levels.php | 1 + .../Fixtures/php/profiler.php | 1 + .../Fixtures/php/property_accessor.php | 1 + .../Fixtures/php/property_info.php | 1 + .../Fixtures/php/request.php | 1 + .../Fixtures/php/serializer_disabled.php | 1 + .../Fixtures/php/serializer_enabled.php | 1 + .../Fixtures/php/serializer_legacy_cache.php | 1 + .../Fixtures/php/serializer_mapping.php | 1 + .../Fixtures/php/session.php | 1 + .../php/session_cookie_secure_auto.php | 1 + .../Fixtures/php/ssi_disabled.php | 1 + .../php/translator_cache_dir_disabled.php | 1 + .../Fixtures/php/translator_fallbacks.php | 1 + .../Fixtures/php/validation_annotations.php | 1 + .../Fixtures/php/validation_auto_mapping.php | 1 + .../php/validation_email_validation_mode.php | 1 + .../Fixtures/php/validation_mapping.php | 1 + .../php/validation_multiple_static_methods.php | 1 + .../php/validation_no_static_method.php | 1 + .../php/validation_translation_domain.php | 1 + .../Fixtures/php/web_link.php | 1 + .../Fixtures/php/workflow_not_valid.php | 1 + .../php/workflow_with_guard_expression.php | 1 + ...ith_multiple_transitions_with_same_name.php | 1 + .../workflow_with_no_events_to_dispatch.php | 1 + ...kflow_with_specified_events_to_dispatch.php | 1 + ...kflow_with_support_and_support_strategy.php | 1 + ...ow_without_support_and_support_strategy.php | 1 + .../Fixtures/php/workflows.php | 1 + .../Fixtures/php/workflows_enabled.php | 1 + .../php/workflows_explicitly_enabled.php | 1 + ...lows_explicitly_enabled_named_workflows.php | 1 + .../Fixtures/xml/assets.xml | 2 +- .../Fixtures/xml/assets_disabled.xml | 2 +- .../xml/assets_version_strategy_as_service.xml | 2 +- .../DependencyInjection/Fixtures/xml/cache.xml | 2 +- .../Fixtures/xml/cache_app_redis_tag_aware.xml | 2 +- .../xml/cache_app_redis_tag_aware_pool.xml | 2 +- .../DependencyInjection/Fixtures/xml/csrf.xml | 2 +- .../Fixtures/xml/csrf_disabled.xml | 2 +- .../Fixtures/xml/csrf_needs_session.xml | 2 +- .../Fixtures/xml/default_config.xml | 2 +- .../xml/esi_and_ssi_without_fragments.xml | 2 +- .../Fixtures/xml/esi_disabled.xml | 2 +- .../Fixtures/xml/exceptions.xml | 2 +- .../Fixtures/xml/form_csrf_sets_field_name.xml | 2 +- .../form_csrf_under_form_sets_field_name.xml | 2 +- .../Fixtures/xml/form_default_csrf.xml | 2 +- .../Fixtures/xml/form_no_csrf.xml | 2 +- .../Fixtures/xml/fragments_and_hinclude.xml | 2 +- .../Fixtures/xml/html_sanitizer.xml | 2 +- .../xml/http_client_default_options.xml | 2 +- .../xml/http_client_full_default_options.xml | 2 +- .../xml/http_client_mock_response_factory.xml | 2 +- .../http_client_override_default_options.xml | 2 +- .../Fixtures/xml/http_client_retry.xml | 2 +- ...http_client_scoped_without_query_option.xml | 2 +- .../Fixtures/xml/http_client_xml_key.xml | 2 +- .../DependencyInjection/Fixtures/xml/lock.xml | 2 +- .../Fixtures/xml/lock_named.xml | 2 +- .../xml/mailer_with_disabled_message_bus.xml | 2 +- .../Fixtures/xml/mailer_with_dsn.xml | 2 +- .../xml/mailer_with_specific_message_bus.xml | 2 +- .../Fixtures/xml/mailer_with_transports.xml | 2 +- .../Fixtures/xml/messenger.xml | 2 +- .../Fixtures/xml/messenger_disabled.xml | 2 +- .../Fixtures/xml/messenger_multiple_buses.xml | 2 +- .../messenger_multiple_failure_transports.xml | 2 +- ...nger_multiple_failure_transports_global.xml | 2 +- .../Fixtures/xml/messenger_routing.xml | 2 +- .../messenger_routing_invalid_transport.xml | 2 +- .../Fixtures/xml/messenger_routing_single.xml | 2 +- .../Fixtures/xml/messenger_transport.xml | 2 +- .../Fixtures/xml/messenger_transports.xml | 2 +- ...essenger_with_disabled_reset_on_message.xml | 2 +- ...er_with_explict_reset_on_message_legacy.xml | 2 +- .../Fixtures/xml/notifier.xml | 2 +- .../Fixtures/xml/notifier_without_mailer.xml | 2 +- .../xml/notifier_without_messenger.xml | 2 +- .../xml/notifier_without_transports.xml | 2 +- .../Fixtures/xml/php_errors_disabled.xml | 2 +- .../Fixtures/xml/php_errors_enabled.xml | 2 +- .../Fixtures/xml/php_errors_log_level.xml | 2 +- .../Fixtures/xml/php_errors_log_levels.xml | 2 +- .../Fixtures/xml/profiler.xml | 2 +- .../Fixtures/xml/property_accessor.xml | 2 +- .../Fixtures/xml/property_info.xml | 2 +- .../Fixtures/xml/request.xml | 2 +- .../Fixtures/xml/semaphore.xml | 2 +- .../Fixtures/xml/serializer_disabled.xml | 2 +- .../Fixtures/xml/serializer_enabled.xml | 2 +- .../Fixtures/xml/serializer_legacy_cache.xml | 2 +- .../Fixtures/xml/serializer_mapping.xml | 2 +- .../Fixtures/xml/session.xml | 2 +- .../xml/session_cookie_secure_auto.xml | 2 +- .../Fixtures/xml/ssi_disabled.xml | 2 +- .../xml/translator_cache_dir_disabled.xml | 2 +- .../Fixtures/xml/translator_fallbacks.xml | 2 +- .../Fixtures/xml/validation_annotations.xml | 2 +- .../Fixtures/xml/validation_auto_mapping.xml | 2 +- .../xml/validation_email_validation_mode.xml | 2 +- .../Fixtures/xml/validation_mapping.xml | 2 +- .../xml/validation_multiple_static_methods.xml | 2 +- .../xml/validation_no_static_method.xml | 2 +- .../xml/validation_translation_domain.xml | 2 +- .../Fixtures/xml/web_link.xml | 2 +- .../Fixtures/xml/workflow_not_valid.xml | 2 +- .../xml/workflow_with_guard_expression.xml | 2 +- ...ith_multiple_transitions_with_same_name.xml | 2 +- .../workflow_with_no_events_to_dispatch.xml | 2 +- ...kflow_with_specified_events_to_dispatch.xml | 2 +- ...kflow_with_support_and_support_strategy.xml | 2 +- ...ow_without_support_and_support_strategy.xml | 2 +- .../Fixtures/xml/workflows.xml | 2 +- .../Fixtures/xml/workflows_enabled.xml | 2 +- .../xml/workflows_explicitly_enabled.xml | 2 +- ...lows_explicitly_enabled_named_workflows.xml | 2 +- .../Fixtures/yml/assets.yml | 1 + .../Fixtures/yml/assets_disabled.yml | 1 + .../yml/assets_version_strategy_as_service.yml | 1 + .../DependencyInjection/Fixtures/yml/cache.yml | 1 + .../Fixtures/yml/cache_app_redis_tag_aware.yml | 1 + .../yml/cache_app_redis_tag_aware_pool.yml | 1 + .../DependencyInjection/Fixtures/yml/csrf.yml | 1 + .../Fixtures/yml/csrf_needs_session.yml | 1 + .../Fixtures/yml/default_config.yml | 3 ++- .../yml/esi_and_ssi_without_fragments.yml | 1 + .../Fixtures/yml/esi_disabled.yml | 1 + .../Fixtures/yml/exceptions.yml | 1 + .../Fixtures/yml/form_default_csrf.yml | 1 + .../Fixtures/yml/form_no_csrf.yml | 1 + .../Fixtures/yml/fragments_and_hinclude.yml | 1 + .../Fixtures/yml/html_sanitizer.yml | 1 + .../yml/http_client_default_options.yml | 1 + .../yml/http_client_full_default_options.yml | 1 + .../yml/http_client_mock_response_factory.yml | 1 + .../http_client_override_default_options.yml | 1 + .../Fixtures/yml/http_client_retry.yml | 1 + ...http_client_scoped_without_query_option.yml | 1 + .../Fixtures/yml/http_client_xml_key.yml | 1 + .../DependencyInjection/Fixtures/yml/lock.yml | 1 + .../Fixtures/yml/lock_named.yml | 1 + .../yml/mailer_with_disabled_message_bus.yml | 1 + .../Fixtures/yml/mailer_with_dsn.yml | 1 + .../yml/mailer_with_specific_message_bus.yml | 1 + .../Fixtures/yml/mailer_with_transports.yml | 1 + .../Fixtures/yml/messenger.yml | 1 + .../Fixtures/yml/messenger_disabled.yml | 1 + ...ger_middleware_factory_erroneous_format.yml | 1 + .../Fixtures/yml/messenger_multiple_buses.yml | 1 + .../messenger_multiple_failure_transports.yml | 1 + ...nger_multiple_failure_transports_global.yml | 1 + .../Fixtures/yml/messenger_routing.yml | 1 + .../messenger_routing_invalid_transport.yml | 1 + .../Fixtures/yml/messenger_routing_single.yml | 1 + .../Fixtures/yml/messenger_transport.yml | 1 + .../Fixtures/yml/messenger_transports.yml | 1 + ...essenger_with_disabled_reset_on_message.yml | 1 + ...er_with_explict_reset_on_message_legacy.yml | 1 + .../Fixtures/yml/notifier.yml | 1 + .../Fixtures/yml/notifier_without_mailer.yml | 1 + .../yml/notifier_without_messenger.yml | 1 + .../yml/notifier_without_transports.yml | 1 + .../Fixtures/yml/php_errors_disabled.yml | 1 + .../Fixtures/yml/php_errors_enabled.yml | 1 + .../Fixtures/yml/php_errors_log_level.yml | 1 + .../Fixtures/yml/php_errors_log_levels.yml | 1 + .../Fixtures/yml/profiler.yml | 1 + .../Fixtures/yml/property_accessor.yml | 1 + .../Fixtures/yml/property_info.yml | 1 + .../Fixtures/yml/request.yml | 1 + .../Fixtures/yml/semaphore.yml | 1 + .../Fixtures/yml/semaphore_named.yml | 1 + .../Fixtures/yml/serializer_disabled.yml | 1 + .../Fixtures/yml/serializer_enabled.yml | 1 + .../Fixtures/yml/serializer_legacy_cache.yml | 1 + .../Fixtures/yml/serializer_mapping.yml | 1 + .../Fixtures/yml/session.yml | 1 + .../yml/session_cookie_secure_auto.yml | 1 + .../Fixtures/yml/ssi_disabled.yml | 1 + .../yml/translator_cache_dir_disabled.yml | 1 + .../Fixtures/yml/translator_fallbacks.yml | 1 + .../Fixtures/yml/validation_annotations.yml | 1 + .../Fixtures/yml/validation_auto_mapping.yml | 1 + .../yml/validation_email_validation_mode.yml | 1 + .../Fixtures/yml/validation_mapping.yml | 1 + .../yml/validation_multiple_static_methods.yml | 1 + .../yml/validation_no_static_method.yml | 1 + .../yml/validation_translation_domain.yml | 1 + .../Fixtures/yml/web_link.yml | 1 + .../Fixtures/yml/workflow_not_valid.yml | 1 + .../yml/workflow_with_guard_expression.yml | 1 + ...ith_multiple_transitions_with_same_name.yml | 1 + .../workflow_with_no_events_to_dispatch.yml | 1 + ...kflow_with_specified_events_to_dispatch.yml | 1 + ...kflow_with_support_and_support_strategy.yml | 1 + ...ow_without_support_and_support_strategy.yml | 1 + .../Fixtures/yml/workflows.yml | 1 + .../Fixtures/yml/workflows_enabled.yml | 1 + .../yml/workflows_explicitly_enabled.yml | 1 + ...lows_explicitly_enabled_named_workflows.yml | 1 + .../FrameworkExtensionTest.php | 12 ++++++------ .../PhpFrameworkExtensionTest.php | 6 ++++++ .../AutowiringTypes/no_annotations_cache.yml | 1 + .../Functional/app/BundlePaths/config.yml | 1 + .../Functional/app/CachePoolClear/config.yml | 1 + .../Tests/Functional/app/CachePools/config.yml | 1 + .../Functional/app/CachePools/redis_config.yml | 1 + .../app/CachePools/redis_custom_config.yml | 1 + .../Tests/Functional/app/ConfigDump/config.yml | 1 + .../Functional/app/ContainerDump/config.yml | 1 + .../Tests/Functional/app/Fragment/config.yml | 1 + .../Tests/Functional/app/Mailer/config.yml | 1 + .../Tests/Functional/app/Profiler/config.yml | 1 + .../app/ProfilerCollectParameter/config.yml | 1 + .../Tests/Functional/app/Serializer/config.yml | 1 + .../Tests/Functional/app/Slugger/config.yml | 1 + .../app/TestServiceContainer/config.yml | 1 + .../app/TestServiceContainer/test_disabled.yml | 1 + .../Tests/Functional/app/TransDebug/config.yml | 1 + .../Functional/app/Uid/config_disabled.yml | 1 + .../Functional/app/Uid/config_enabled.yml | 1 + .../Tests/Functional/app/config/framework.yml | 1 + .../Tests/Kernel/ConcreteMicroKernel.php | 1 + .../Tests/Kernel/MicroKernelTraitTest.php | 1 + .../flex-style/src/FlexStyleMicroKernel.php | 2 +- .../AddSessionDomainConstraintPassTest.php | 2 +- .../Functional/app/Authenticator/config.yml | 1 + .../app/FirewallEntryPoint/config.yml | 1 + .../Tests/Functional/app/JsonLogin/config.yml | 1 + .../Functional/app/JsonLogin/legacy_config.yml | 1 + .../app/RememberMe/stateless_config.yml | 1 + .../app/StandardFormLogin/login_throttling.yml | 1 + .../Tests/Functional/app/config/framework.yml | 1 + .../Tests/Functional/NoTemplatingEntryTest.php | 1 + .../Functional/WebProfilerBundleKernel.php | 1 + 292 files changed, 333 insertions(+), 101 deletions(-) diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md index 1b66c0ece04d..ee3b5bad5cfd 100644 --- a/UPGRADE-6.1.md +++ b/UPGRADE-6.1.md @@ -25,6 +25,7 @@ FrameworkBundle * Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now. To prevent services resetting after each message the "--no-reset" option in "messenger:consume" command can be set + * Deprecate not setting the `http_method_override` config option. The default value will change to `false` in 7.0. HttpKernel ---------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 1751a123bba5..0a1c48cc28e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -14,6 +14,7 @@ CHANGELOG * Add support for first-class callable route controller in `MicroKernelTrait` * Add tag `routing.condition_service` to autoconfigure routing condition services * Automatically register kernel methods marked with the `Symfony\Component\Routing\Annotation\Route` attribute or annotation as controllers in `MicroKernelTrait` + * Deprecate not setting the `http_method_override` config option. The default value will change to `false` in 7.0. 6.0 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 5794020b4447..92f7cbc9a93a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -76,12 +76,23 @@ public function getConfigTreeBuilder(): TreeBuilder return $v; }) ->end() + ->validate() + ->always(function ($v) { + if (!isset($v['http_method_override'])) { + trigger_deprecation('symfony/framework-bundle', '6.1', 'Not setting the "framework.http_method_override" config option is deprecated. It will default to "false" in 7.0.'); + + $v['http_method_override'] = true; + } + + return $v; + }) + ->end() ->fixXmlConfig('enabled_locale') ->children() ->scalarNode('secret')->end() - ->scalarNode('http_method_override') + ->booleanNode('http_method_override') ->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead") - ->defaultTrue() + ->treatNullLike(false) ->end() ->scalarNode('trust_x_sendfile_type_header') ->info('Set true to enable support for xsendfile in binary file responses.') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/Fixture/TestAppKernel.php index c15bf83cb1cf..cc55da770ed2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/Fixture/TestAppKernel.php @@ -32,6 +32,11 @@ public function getProjectDir(): string public function registerContainerConfiguration(LoaderInterface $loader) { + $loader->load(static function (ContainerBuilder $container) { + $container->loadFromExtension('framework', [ + 'http_method_override' => false, + ]); + }); } protected function build(ContainerBuilder $container) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/config.yml index 68f8d040610c..449f26f2b7d1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/config.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false secret: test diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 07612df73719..cc567b14829e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -33,7 +33,7 @@ class ConfigurationTest extends TestCase public function testDefaultConfig() { $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(true), [['secret' => 's3cr3t']]); + $config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t']]); $this->assertEquals(self::getBundleDefaultConfig(), $config); } @@ -57,7 +57,7 @@ public function testInvalidSessionName($sessionName) $processor = new Processor(); $processor->processConfiguration( new Configuration(true), - [['session' => ['name' => $sessionName]]] + [['http_method_override' => false, 'session' => ['name' => $sessionName]]] ); } @@ -77,7 +77,7 @@ public function testAssetsCanBeEnabled() { $processor = new Processor(); $configuration = new Configuration(true); - $config = $processor->processConfiguration($configuration, [['assets' => null]]); + $config = $processor->processConfiguration($configuration, [['http_method_override' => false, 'assets' => null]]); $defaultConfig = [ 'enabled' => true, @@ -103,6 +103,7 @@ public function testValidAssetsPackageNameConfiguration($packageName) $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'assets' => [ 'packages' => [ $packageName => [], @@ -135,6 +136,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess $configuration = new Configuration(true); $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'assets' => $assetConfig, ], ]); @@ -184,6 +186,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig) $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'lock' => $lockConfig, ], ]); @@ -244,11 +247,13 @@ public function testLockMergeConfigs() $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'lock' => [ 'payload' => 'flock', ], ], [ + 'http_method_override' => false, 'lock' => [ 'payload' => 'semaphore', ], @@ -275,6 +280,7 @@ public function testValidSemaphoreConfiguration($semaphoreConfig, $processedConf $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'semaphore' => $semaphoreConfig, ], ]); @@ -327,6 +333,7 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau $processor->processConfiguration($configuration, [ 'framework' => [ + 'http_method_override' => false, 'messenger' => [ 'default_bus' => null, 'buses' => [ @@ -344,6 +351,7 @@ public function testBusMiddlewareDontMerge() $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'messenger' => [ 'default_bus' => 'existing_bus', 'buses' => [ @@ -358,6 +366,7 @@ public function testBusMiddlewareDontMerge() ], ], [ + 'http_method_override' => false, 'messenger' => [ 'buses' => [ 'common_bus' => [ @@ -406,6 +415,7 @@ public function testItErrorsWhenDefaultBusDoesNotExist() $processor->processConfiguration($configuration, [ [ + 'http_method_override' => false, 'messenger' => [ 'default_bus' => 'foo', 'buses' => [ @@ -420,7 +430,7 @@ public function testItErrorsWhenDefaultBusDoesNotExist() protected static function getBundleDefaultConfig() { return [ - 'http_method_override' => true, + 'http_method_override' => false, 'trust_x_sendfile_type_header' => false, 'ide' => '%env(default::SYMFONY_IDE)%', 'default_locale' => 'en', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php index f26621001c9e..4b71fb9c751c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'assets' => [ 'version' => 'SomeVersionScheme', 'base_urls' => 'http://cdn.example.com', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php index d10595fba9df..0513da761df9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'assets' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php index b57f78ba47bb..611259c00c4f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'assets' => [ 'version_strategy' => 'assets.custom_version_strategy', 'base_urls' => 'http://cdn.example.com', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php index 9ca04b6c63bf..13b659b6327a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'cache' => [ 'pools' => [ 'cache.foo' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware.php index 44855c62adbf..ca8834fc3697 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'cache' => [ 'app' => 'cache.adapter.redis_tag_aware', ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware_pool.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware_pool.php index bf3ee2de2b35..3ca0f1c77bfe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware_pool.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_app_redis_tag_aware_pool.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'cache' => [ 'app' => 'cache.redis_tag_aware.foo', 'pools' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php index 8b712475fda5..9db840d5194c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'csrf_protection' => true, 'session' => [ 'storage_factory_id' => 'session.storage.factory.native', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php index 34fdb4c1f993..2e1a54221a28 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'csrf_protection' => [ 'enabled' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php index 4b2021df7bb2..34e2894f9fb9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php @@ -1,3 +1,4 @@ loadFromExtension('framework', []); +$container->loadFromExtension('framework', [ + 'http_method_override' => false,]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php index beada36b8435..facad13cdf78 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'fragments' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php index a24cd8158c6b..76e3ddfbe766 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'esi' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/exceptions.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/exceptions.php index 5d0dde0e0ac6..4d9fd9486237 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/exceptions.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/exceptions.php @@ -3,6 +3,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'exceptions' => [ BadRequestHttpException::class => [ 'log_level' => 'info', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_default_csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_default_csrf.php index a57d5233806f..0c491714a05a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_default_csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_default_csrf.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'form' => [ 'legacy_error_messages' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php index e0befdb32061..53eaad266877 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'form' => [ 'csrf_protection' => [ 'enabled' => false, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php index dbcf5b786dba..0f3ee9c194a9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'fragments' => [ 'enabled' => true, 'hinclude_default_template' => 'global_hinclude_template', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/html_sanitizer.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/html_sanitizer.php index e7b1bd41fc36..687f05a3ffa2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/html_sanitizer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/html_sanitizer.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'html_sanitizer' => [ 'default' => 'my.sanitizer', 'sanitizers' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_default_options.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_default_options.php index 5f71a92847f3..b8f63d8190b8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_default_options.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_default_options.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'max_host_connections' => 4, 'default_options' => null, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_full_default_options.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_full_default_options.php index cf83e31af2f0..865ddd14e120 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_full_default_options.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_full_default_options.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'default_options' => [ 'headers' => ['X-powered' => 'PHP'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_mock_response_factory.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_mock_response_factory.php index 5b64c3ae0a1d..de2dd604e3f8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_mock_response_factory.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_mock_response_factory.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'default_options' => null, 'mock_response_factory' => 'my_response_factory', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_override_default_options.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_override_default_options.php index 8ba8dd7b92ec..c66ce8851b42 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_override_default_options.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_override_default_options.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'max_host_connections' => 4, 'default_options' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_retry.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_retry.php index f2ab01d1e119..63914440a7be 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_retry.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_retry.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'default_options' => [ 'retry_failed' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php index 0d3dc88472f8..653ca421846a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'scoped_clients' => [ 'foo' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php index 64778c61561b..d613dc05d2fd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'http_client' => [ 'default_options' => [ 'resolve' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php index a585c6ee5de6..46acfce8c144 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => 's3cr3t', 'default_locale' => 'fr', 'router' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer.php index 5e3093b33b43..918d837c411f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'dsn' => 'smtp://example.com', 'envelope' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_disabled_message_bus.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_disabled_message_bus.php index 4f2471ed9580..bea83e8fe66c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_disabled_message_bus.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_disabled_message_bus.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'dsn' => 'smtp://example.com', 'message_bus' => false, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php index df2ca46e46ee..3d991932e7e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php @@ -4,6 +4,7 @@ return static function (ContainerConfigurator $container) { $container->extension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'dsn' => 'smtp://example.com', 'envelope' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_specific_message_bus.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_specific_message_bus.php index 32b936af9d88..ba9e9f573b56 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_specific_message_bus.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_specific_message_bus.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'dsn' => 'smtp://example.com', 'message_bus' => 'app.another_bus', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_transports.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_transports.php index 8b13bc269b24..bc1a7925d8e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_transports.php @@ -4,6 +4,7 @@ return static function (ContainerConfigurator $container) { $container->extension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'transports' => [ 'transport1' => 'smtp://example1.com', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger.php index adb8239d0473..dc22cd5ff891 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'routing' => [ FooMessage::class => ['sender.bar', 'sender.biz'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_disabled.php index e02542d9778c..d14d6e94b617 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_disabled.php @@ -1,5 +1,6 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => false, ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_middleware_factory_erroneous_format.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_middleware_factory_erroneous_format.php index cb4ee5e5127b..6d8e6bbffbb2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_middleware_factory_erroneous_format.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_middleware_factory_erroneous_format.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'buses' => [ 'command_bus' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses.php index 627e21f3084e..665c664bfb21 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'default_bus' => 'messenger.bus.commands', 'buses' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports.php index 8f85259aa690..30b000f9bb5a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'transports' => [ 'transport_1' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports_global.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports_global.php index 0cff76887b15..3848ee59f7ad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports_global.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_failure_transports_global.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'failure_transport' => 'failure_transport_global', 'transports' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing.php index eb459509015d..77f4d5b93beb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => true, 'messenger' => [ 'serializer' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_invalid_transport.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_invalid_transport.php index ee77e3a3f2db..b552a3ebe5d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_invalid_transport.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_invalid_transport.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => true, 'messenger' => [ 'serializer' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php index e58814589b87..f487a0f8f90d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'routing' => [ 'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => ['amqp'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transport.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transport.php index 7baab29dc57c..34f95dbee6e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transport.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transport.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => true, 'messenger' => [ 'serializer' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transports.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transports.php index 90c5def3ac10..8236fced4502 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_transports.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => true, 'messenger' => [ 'failure_transport' => 'failed', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_disabled_reset_on_message.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_disabled_reset_on_message.php index dda2e30108b8..3cb006c46750 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_disabled_reset_on_message.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_disabled_reset_on_message.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'reset_on_message' => false, 'routing' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_explict_reset_on_message_legacy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_explict_reset_on_message_legacy.php index 73102d522db5..ee689ae0932d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_explict_reset_on_message_legacy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_with_explict_reset_on_message_legacy.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'reset_on_message' => true, 'routing' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier.php index 5ffe142be4df..f51708471355 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'messenger' => [ 'enabled' => true ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_mailer.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_mailer.php index 6d51ef98517f..a1cea02ac86d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_mailer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_mailer.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_messenger.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_messenger.php index 454cf5ef7ca8..bc4280b97a55 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_messenger.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_messenger.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'mailer' => [ 'dsn' => 'smtp://example.com', ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_transports.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_transports.php index 9bc87dbee2f5..0d3223198528 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/notifier_without_transports.php @@ -4,6 +4,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'notifier' => [ 'enabled' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php index cff0582bf3b3..0e552a97853d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'php_errors' => [ 'log' => false, 'throw' => false, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php index 9afa5d1c0226..f26bf7da296e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'php_errors' => [ 'log' => true, 'throw' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_level.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_level.php index 87fdd64d0b6f..997ea4c39310 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_level.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_level.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'php_errors' => [ 'log' => 8, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php index 620a5871e098..72f4685af1ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'php_errors' => [ 'log' => [ \E_NOTICE => \Psr\Log\LogLevel::ERROR, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php index 552c95e137bb..955da41fab43 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'profiler' => [ 'enabled' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php index dc6954fe89da..cce084b77fa6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'property_access' => [ 'magic_call' => true, 'magic_get' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php index bff8d4115858..bbf4b58b4ec5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'property_info' => [ 'enabled' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php index d69d7512ad99..2a1a9d10d746 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'request' => [ 'formats' => [], ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php index 937a07c2255c..d8ec0560a8c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php index de3381c21e3a..f40405e7a011 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => [ 'enabled' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php index 9636b1d6613a..6695d9f7988b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'serializer' => [ 'enabled' => true, 'cache' => 'foo', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php index 2f6f48e95888..d68a9f76f769 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'annotations' => ['enabled' => true], 'serializer' => [ 'enable_annotations' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php index 8b4c6e6e4c3b..1f2556a5cfcb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'session' => [ 'storage_factory_id' => 'session.storage.factory.native', 'handler_id' => null, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session_cookie_secure_auto.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session_cookie_secure_auto.php index b52935c726a0..b07b6f8b2f1a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session_cookie_secure_auto.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session_cookie_secure_auto.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'session' => [ 'storage_factory_id' => 'session.storage.factory.native', 'handler_id' => null, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php index 32e1bf0c554d..f1c56a38cd58 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'ssi' => [ 'enabled' => false, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_cache_dir_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_cache_dir_disabled.php index 6f2568ffd511..92383e5a9bd1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_cache_dir_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_cache_dir_disabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'translator' => [ 'cache_dir' => null, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php index 592a61de65a7..0989890ee454 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'translator' => [ 'fallbacks' => ['en', 'fr'], ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php index 933410dfee76..cb2bf7f3f597 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => 's3cr3t', 'validation' => [ 'enabled' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_mapping.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_mapping.php index e15762d6d8a1..4d879f6c5d88 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_mapping.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_mapping.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'property_info' => ['enabled' => true], 'validation' => [ 'auto_mapping' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_email_validation_mode.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_email_validation_mode.php index 5100e01e12bb..75a12bbd98af 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_email_validation_mode.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_email_validation_mode.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'validation' => [ 'email_validation_mode' => 'html5', ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php index f8b19e34801c..6be94689035d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'validation' => [ 'mapping' => [ 'paths' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php index ad2bd817a208..475bb595a818 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => 's3cr3t', 'validation' => [ 'enabled' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php index a9d98e17c68d..8adb5c26b8b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => 's3cr3t', 'validation' => [ 'enabled' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php index 42ea0713030a..104dbbace0c8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'validation' => [ 'translation_domain' => 'messages', ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php index 44d52e402d8b..5b022da2067d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php @@ -1,5 +1,6 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'web_link' => ['enabled' => true], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php index 5d6ed54d6739..efb5767a3b53 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'my_workflow' => [ 'type' => 'state_machine', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php index 2037b5f904f6..37a1d7ac7300 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'article' => [ 'type' => 'workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php index 35a9df3730b2..2ba2b3491c70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'article' => [ 'type' => 'workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php index e4eefd4c2844..81fe174b1b2a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'my_workflow' => [ 'type' => 'state_machine', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php index 0fc5c29c8b43..1c434cd99c4e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'my_workflow' => [ 'type' => 'state_machine', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php index 063755b130d3..120bb364722d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'my_workflow' => [ 'type' => 'workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php index 5eef5cc4d082..641455eb36b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'my_workflow' => [ 'type' => 'workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php index 995fabffe38b..5cdb2563ac2b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'article' => [ 'type' => 'workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php index eb1773194097..9f2fabe3e57e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php @@ -1,5 +1,6 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => null, ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php index f048de1ceb5a..ad71b2729853 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'enabled' => true, 'foo' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php index f79a2d10e97f..49ab48914e1b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php @@ -1,6 +1,7 @@ loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'enabled' => true, 'workflows' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml index dadee4529d8b..bb4b62ee6a0c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.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"> - + http://cdn.example.com diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_disabled.xml index 3c1303144b51..cd53b664d441 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_disabled.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_version_strategy_as_service.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_version_strategy_as_service.xml index 7bc70332bcc9..0a7e6bc3ff3b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_version_strategy_as_service.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets_version_strategy_as_service.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"> - + http://cdn.example.com diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml index 7c75178c8cf0..a0ae5219ba9a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware.xml index 2929e87e200e..630c2385c597 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware.xml @@ -5,7 +5,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"> - + cache.adapter.redis_tag_aware diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware_pool.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware_pool.xml index 65c06a1da6df..40ce365c5bda 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware_pool.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_app_redis_tag_aware_pool.xml @@ -5,7 +5,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"> - + cache.redis_tag_aware.foo diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml index 24acb3e32707..97104d0571e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml index 63a26d384397..7f9ff7fb9250 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml index a9e168638df3..013435d6b6ba 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/default_config.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/default_config.xml index d98c43d992d8..efbd656c0a13 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/default_config.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/default_config.xml @@ -5,5 +5,5 @@ 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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_and_ssi_without_fragments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_and_ssi_without_fragments.xml index 5fe9be69b7cb..70dd10405580 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_and_ssi_without_fragments.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_and_ssi_without_fragments.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_disabled.xml index d4a46b62fcfb..961882a6a58d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/esi_disabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/exceptions.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/exceptions.xml index cc73b8de3ced..d40de006d731 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/exceptions.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/exceptions.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml index 30fcf6b7f392..55616c2d6a7a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml index 1e89bca965ea..cf88a085adc5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_default_csrf.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_default_csrf.xml index 9ed40084722b..c2700a6b20a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_default_csrf.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_default_csrf.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_no_csrf.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_no_csrf.xml index 3af5322be212..afb1869c5ab5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_no_csrf.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_no_csrf.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml index fb007313b9a7..2031cac377cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/html_sanitizer.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/html_sanitizer.xml index 05cf704dd2c6..77a47724541b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/html_sanitizer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/html_sanitizer.xml @@ -5,7 +5,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"> - + - + - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_override_default_options.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_override_default_options.xml index 8dd84123ca4b..fdee9a9132a3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_override_default_options.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_override_default_options.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_retry.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_retry.xml index eb7798914488..248fd81801e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_retry.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_retry.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + - + - + 127.0.0.1 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock.xml index d531fbaba218..d16fa7e5bf7f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml index 72e583a90239..b44dd675ffdc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml @@ -10,7 +10,7 @@ redis://paas.com - + semaphore flock diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_disabled_message_bus.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_disabled_message_bus.xml index e6d3a47e38a9..cac6ba833daa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_disabled_message_bus.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_disabled_message_bus.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml index be53f59bc3ca..fc4f9861e98e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.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"> - + sender@example.org diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_specific_message_bus.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_specific_message_bus.xml index 116ba032a03a..ee541be7f94b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_specific_message_bus.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_specific_message_bus.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml index cbe538d33e99..71cd4c118a1f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.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"> - + smtp://example1.com smtp://example2.com diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger.xml index bacd772dcb6f..fef09b934a3a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_disabled.xml index 6f57398b30d2..513842ece839 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_disabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses.xml index 1642e5798850..a8f515e7166b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports.xml index b8e9f1975942..bad9fb16fb67 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports_global.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports_global.xml index c6e5c530fda1..096c26f4628a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports_global.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_failure_transports_global.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing.xml index 0b022e78a0c8..30b249b415c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_invalid_transport.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_invalid_transport.xml index 98c487fbf8bf..cbff44e09f59 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_invalid_transport.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_invalid_transport.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml index 349a3728d393..972f5201fb38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transport.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transport.xml index e5e60a39823a..f2e7cfc6c49b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transport.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transport.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transports.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transports.xml index b0510d580cea..d78c802810ae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transports.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_transports.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_disabled_reset_on_message.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_disabled_reset_on_message.xml index 67a2a414e8fc..c0bc33bcde15 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_disabled_reset_on_message.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_disabled_reset_on_message.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_explict_reset_on_message_legacy.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_explict_reset_on_message_legacy.xml index 1451bb66f516..4c208aad2f0b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_explict_reset_on_message_legacy.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_with_explict_reset_on_message_legacy.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier.xml index 47e2e2b0c1b1..8c675c460378 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_mailer.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_mailer.xml index 1c62b5265b89..a93064b21384 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_mailer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_mailer.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_messenger.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_messenger.xml index c2a513476258..7d65d064e994 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_messenger.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_messenger.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_transports.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_transports.xml index a1ec7863cda1..ee6653c3449e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_transports.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/notifier_without_transports.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_disabled.xml index cb50daa65e88..62d677a54e74 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_disabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_enabled.xml index db6a8a9bf03c..a57c4e6c6843 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_enabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_enabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_level.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_level.xml index ebd7948452b7..608842c27b48 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_level.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_level.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml index 1b6642a575c4..004a6d328422 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml index a5f5448e18f2..9b157c920d11 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml index 9406919e9239..aacbb7531a16 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_info.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_info.xml index 7bf63b6540c5..112635383e6a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_info.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_info.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml index f1e8184c149d..0bcabe269726 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml @@ -5,7 +5,7 @@ xmlns:framework="http://symfony.com/schema/dic/symfony" 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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/semaphore.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/semaphore.xml index 0b2f6c662dcf..be7264689f3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/semaphore.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/semaphore.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_disabled.xml index 0c62272c5100..b5d55599e0e1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_disabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_enabled.xml index 3d59d62833ea..a0b95b01e1e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_enabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_enabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml index b76ceb86b714..9296670bb165 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml index 1ae06c85e13c..988abf90e058 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session.xml index e91d51955e6f..338404bc8688 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session_cookie_secure_auto.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session_cookie_secure_auto.xml index 3023c43fc13a..7b9408e89788 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session_cookie_secure_auto.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session_cookie_secure_auto.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/ssi_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/ssi_disabled.xml index 6aa752a4695d..054f191f1ea1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/ssi_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/ssi_disabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_cache_dir_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_cache_dir_disabled.xml index 5704ff7cd7dd..229a72286024 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_cache_dir_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_cache_dir_disabled.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml index 521f8e381512..d6b09f34ee46 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.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"> - + en fr diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml index 2324b9ca6e37..42bcdc3f47d9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_mapping.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_mapping.xml index a05aaf8016a5..71109f8e44ae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_mapping.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_mapping.xml @@ -3,7 +3,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_email_validation_mode.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_email_validation_mode.xml index 7274d815894d..961b9adba453 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_email_validation_mode.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_email_validation_mode.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_mapping.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_mapping.xml index 8d74ebb2118f..ad70508b6bfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_mapping.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_mapping.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony"> - + %kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_multiple_static_methods.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_multiple_static_methods.xml index c2e84c3b906c..abd9ba9b740f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_multiple_static_methods.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_multiple_static_methods.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"> - + loadFoo loadBar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_no_static_method.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_no_static_method.xml index 61770d88a7fa..7554cd16f281 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_no_static_method.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_no_static_method.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml index 3690f9e10eda..05ad899763c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/web_link.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/web_link.xml index 718ceb31a372..9c617ccbdea9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/web_link.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/web_link.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml index df299c89deb5..12bc1b463b68 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml index ffc12c4d0d42..1a953f96352e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.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"> - + draft Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml index db79f9323c47..3bf4657eccac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.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"> - + draft Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml index 2f563da4bf96..4fc6a02341fd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + one diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml index d442828f8cfb..48091a9b0118 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + one diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml index 54a346ebda19..139259826af2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.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"> - + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_without_support_and_support_strategy.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_without_support_and_support_strategy.xml index c6ee7d77b5c6..b40b24707a87 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_without_support_and_support_strategy.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_without_support_and_support_strategy.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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml index 79361af57a61..5e9f1d1bff70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.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"> - + draft diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_enabled.xml index 26e622e9e007..a5567a8101d0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_enabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_enabled.xml @@ -5,7 +5,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"> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml index af93d44e1838..a3d7f8bfa623 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml @@ -5,7 +5,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"> - + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml index 41fd29a1f27d..3569297c4578 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml @@ -5,7 +5,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"> - + bar Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml index cfd4f07b0434..2c1450de8cc7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false assets: version: SomeVersionScheme version_format: '%%s?version=%%s' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_disabled.yml index 17ba4e90afb7..baa169f48ce7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false assets: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_version_strategy_as_service.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_version_strategy_as_service.yml index 2528462f83cb..cdfc43ca648e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_version_strategy_as_service.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets_version_strategy_as_service.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false assets: version_strategy: assets.custom_version_strategy base_urls: http://cdn.example.com diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml index c89c027f5aec..b886dcd1b3ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false cache: pools: cache.foo: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware.yml index b1c89adafa0c..11204defe4d3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false cache: app: cache.adapter.redis_tag_aware diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware_pool.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware_pool.yml index 9eb8b83c775c..42717b2aa51b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware_pool.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_app_redis_tag_aware_pool.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false cache: app: cache.redis_tag_aware.foo pools: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml index 643e7bda4554..71f6a34e22d2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: s3cr3t csrf_protection: ~ session: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml index b8065b6fb678..8fb542365010 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false csrf_protection: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/default_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/default_config.yml index 00874fbe8d11..26f9bb5a672a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/default_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/default_config.yml @@ -1 +1,2 @@ -framework: ~ +framework: + http_method_override: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_and_ssi_without_fragments.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_and_ssi_without_fragments.yml index 49d63c8d60a1..a1140cc31c04 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_and_ssi_without_fragments.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_and_ssi_without_fragments.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false fragments: enabled: false esi: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_disabled.yml index 2a78e6da0e72..9e9a03f072ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/esi_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false esi: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/exceptions.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/exceptions.yml index 82fab4e04a9f..9ee4351dc760 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/exceptions.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/exceptions.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false exceptions: Symfony\Component\HttpKernel\Exception\BadRequestHttpException: log_level: info diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_default_csrf.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_default_csrf.yml index 5036cc857773..d6e9d77b9367 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_default_csrf.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_default_csrf.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false form: legacy_error_messages: false session: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_no_csrf.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_no_csrf.yml index e3ac7e8daf42..7f1d94ad2040 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_no_csrf.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_no_csrf.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false form: csrf_protection: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml index b03f37da7946..92dc6fe7771c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false fragments: enabled: true hinclude_default_template: global_hinclude_template diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/html_sanitizer.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/html_sanitizer.yml index 1c4f5dfcd5a4..815ca37cfc5a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/html_sanitizer.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/html_sanitizer.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false html_sanitizer: default: my.sanitizer sanitizers: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_default_options.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_default_options.yml index 6828f8ec231f..4bc3637624fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_default_options.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_default_options.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: max_host_connections: 4 default_options: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_full_default_options.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_full_default_options.yml index ba3aa46259b4..de9300e17f15 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_full_default_options.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_full_default_options.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: default_options: headers: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_mock_response_factory.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_mock_response_factory.yml index b95859108413..a90016a026e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_mock_response_factory.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_mock_response_factory.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: default_options: ~ mock_response_factory: my_response_factory diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_override_default_options.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_override_default_options.yml index 1528a313d64e..14a6915380db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_override_default_options.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_override_default_options.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: max_host_connections: 4 default_options: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_retry.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_retry.yml index eba686819c30..9f02eb5bce2b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_retry.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_retry.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: default_options: retry_failed: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml index ecfc9d41fd4c..8da495f14e63 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: scoped_clients: foo: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml index dc87555a901a..51ac6c30a1ac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false http_client: default_options: resolve: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock.yml index 70f578a143a5..3ca4a46ab863 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false lock: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml index 6d0cb5ca638b..02ffcf5b71c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml @@ -2,6 +2,7 @@ parameters: env(REDIS_DSN): redis://paas.com framework: + http_method_override: false lock: foo: semaphore bar: flock diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_disabled_message_bus.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_disabled_message_bus.yml index f941f7c8c4f6..180be920d08c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_disabled_message_bus.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_disabled_message_bus.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: dsn: 'smtp://example.com' message_bus: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml index f8b3c87c4302..8677cc5ece83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: dsn: 'smtp://example.com' envelope: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_specific_message_bus.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_specific_message_bus.yml index ddfc7a479a49..bc227c96cf79 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_specific_message_bus.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_specific_message_bus.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: dsn: 'smtp://example.com' message_bus: app.another_bus diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_transports.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_transports.yml index bc4657d3a439..6486fdeeedf1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_transports.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_transports.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: transports: transport1: 'smtp://example1.com' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger.yml index 82fea3b27af2..29174a9b407f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: routing: 'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage': ['sender.bar', 'sender.biz'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_disabled.yml index 1b2d2d1a4f47..8bbd594e3839 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_disabled.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false messenger: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_middleware_factory_erroneous_format.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_middleware_factory_erroneous_format.yml index 74431414ba99..fcafe4b57b97 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_middleware_factory_erroneous_format.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_middleware_factory_erroneous_format.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: buses: command_bus: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses.yml index 0e6703973327..0699ecfaed0a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: default_bus: messenger.bus.commands buses: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports.yml index 863f18a7d1a1..04e6d1f24e20 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: transports: transport_1: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports_global.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports_global.yml index 10023edb0b9f..bac747b7a1b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports_global.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_failure_transports_global.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: failure_transport: failure_transport_global transports: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing.yml index 0e493eb882a0..bfd682c706fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false serializer: true messenger: serializer: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_invalid_transport.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_invalid_transport.yml index 3bf0f2ddf9c0..3b01d3d3bca3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_invalid_transport.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_invalid_transport.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false serializer: true messenger: serializer: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml index caa88641887c..73544ddda6e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: routing: 'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage': [amqp] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transport.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transport.yml index b51feb73bce9..cc7e613b2889 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transport.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transport.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false serializer: true messenger: serializer: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transports.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transports.yml index d00f4a65dd37..b16f9b6a8f09 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transports.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_transports.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false serializer: true messenger: failure_transport: failed diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_disabled_reset_on_message.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_disabled_reset_on_message.yml index f67395c85c19..37e1e90b530d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_disabled_reset_on_message.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_disabled_reset_on_message.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: reset_on_message: false routing: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_explict_reset_on_message_legacy.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_explict_reset_on_message_legacy.yml index 3bf374f474c7..17b779a254fe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_explict_reset_on_message_legacy.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_with_explict_reset_on_message_legacy.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: reset_on_message: true routing: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier.yml index 586cb98a4a13..da8e3fa7a46d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false messenger: enabled: true mailer: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_mailer.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_mailer.yml index 75fa3cf88982..57febaaeb310 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_mailer.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_mailer.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: enabled: false messenger: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_messenger.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_messenger.yml index 93d1f0aa190a..9ff92d0ac74a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_messenger.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_messenger.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false mailer: dsn: 'smtp://example.com' messenger: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_transports.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_transports.yml index 856b0cd7c7a0..081b7af9f12f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_transports.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/notifier_without_transports.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false notifier: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_disabled.yml index 958f75638ab7..c0091d3c480f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false php_errors: throw: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_enabled.yml index f48531014e4f..9080d5cccca3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_enabled.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false php_errors: log: true throw: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_level.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_level.yml index e5cff7767dbe..0cc44c7e8d1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_level.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_level.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false php_errors: log: 8 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml index ad9fd30667de..c8b4f7e5ebec 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false php_errors: log: !php/const \E_NOTICE: !php/const Psr\Log\LogLevel::ERROR diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml index 9052a2bdfb0c..13279e1958fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false profiler: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml index 931b50383f21..5e83cd44be75 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false property_access: magic_call: true magic_get: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_info.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_info.yml index fbdf7a7b0d71..60b9cb920975 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_info.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_info.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false property_info: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml index 9beae1dc5975..3e57df27cfa4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false request: formats: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore.yml index 47b1323517b4..fe53f99d2e15 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false semaphore: redis://localhost diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore_named.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore_named.yml index 0a29e4ea825e..e1b9d1b69a22 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore_named.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/semaphore_named.yml @@ -2,6 +2,7 @@ parameters: env(REDIS_DSN): redis://paas.com framework: + http_method_override: false semaphore: foo: redis://paas.com qux: "%env(REDIS_DSN)%" diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_disabled.yml index 330e19a6976e..2e9cd798dfad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false serializer: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_enabled.yml index 40a1ff7d65b3..47e8c356c7ed 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_enabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false serializer: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml index 5fadc886ab1b..5fd44373fcdd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false serializer: enabled: true cache: foo diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml index 77c9d517a33b..3291dc2a4777 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false annotations: enabled: true serializer: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session.yml index eb0df8d01c76..51a14623654b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false session: storage_factory_id: session.storage.factory.native handler_id: null diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session_cookie_secure_auto.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session_cookie_secure_auto.yml index 739b49b1e6ab..d89a8f7aa109 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session_cookie_secure_auto.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session_cookie_secure_auto.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false session: storage_factory_id: session.storage.factory.native handler_id: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/ssi_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/ssi_disabled.yml index 3a8a820c7143..f3c359f7b95b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/ssi_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/ssi_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false ssi: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_cache_dir_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_cache_dir_disabled.yml index 6ad1c7330f96..a6745633e011 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_cache_dir_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_cache_dir_disabled.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false translator: cache_dir: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml index 271d78118475..5534797b5b96 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false translator: fallbacks: [en, fr] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml index 97b433f8cfb0..8595a0f533cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: s3cr3t validation: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_mapping.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_mapping.yml index 2564a8d243ef..6a25af86ce34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_mapping.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_mapping.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false property_info: { enabled: true } validation: auto_mapping: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_email_validation_mode.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_email_validation_mode.yml index a695e1a62a7d..e8aebd9976fd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_email_validation_mode.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_email_validation_mode.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false validation: email_validation_mode: html5 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_mapping.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_mapping.yml index f05e33bb6c13..5b9859a3a284 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_mapping.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_mapping.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false validation: mapping: paths: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_multiple_static_methods.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_multiple_static_methods.yml index 6ca343351328..350ef4472612 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_multiple_static_methods.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_multiple_static_methods.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: s3cr3t validation: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_no_static_method.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_no_static_method.yml index ca5214964259..5c4d765ce036 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_no_static_method.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_no_static_method.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: s3cr3t validation: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml index 167b5fcce85b..c8b39054a2c8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false validation: translation_domain: messages diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml index 4276aacbe21c..4cb63387696b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml @@ -1,3 +1,4 @@ framework: + http_method_override: false web_link: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml index 123505de9754..29eeb8e9ad18 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: my_workflow: type: state_machine diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml index 80a85a307b73..6855c013053b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: article: type: workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml index 12df7b79e7c4..384bd47170bf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: article: type: workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml index e0a281f27db4..c511543df056 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: my_workflow: type: state_machine diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml index d5ff3d5e5fe0..703195b55766 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: my_workflow: type: state_machine diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml index de0b36d8fa49..a57bc555b6fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: my_workflow: type: workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_without_support_and_support_strategy.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_without_support_and_support_strategy.yml index de74adbe59b2..9ba3c88399cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_without_support_and_support_strategy.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_without_support_and_support_strategy.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: my_workflow: type: workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml index e4ac9c01890e..ff1b926b0999 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: article: type: workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_enabled.yml index 2a716ff0a1b1..4c5f97f0b2a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_enabled.yml @@ -1,2 +1,3 @@ framework: + http_method_override: false workflows: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml index bbecf4bfc420..1ee334125e3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: enabled: true workflows: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml index 786e3bcad292..0dcfc93a1c20 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false workflows: enabled: true workflows: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 0f31cd1931d3..1050dcf004d8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -573,7 +573,7 @@ public function testRouterRequiresResourceOption() $this->expectException(InvalidConfigurationException::class); $container = $this->createContainer(); $loader = new FrameworkExtension(); - $loader->load([['router' => true]], $container); + $loader->load([['http_method_override' => false, 'router' => true]], $container); } public function testSession() @@ -1721,11 +1721,11 @@ public function testCachePoolInvalidateTagsCommandRegistered() public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug() { $container = $this->createContainer(['kernel.debug' => true]); - (new FrameworkExtension())->load([], $container); + (new FrameworkExtension())->load([['http_method_override' => false]], $container); $this->assertCount(1, $container->getDefinition('config_cache_factory')->getArguments()); $container = $this->createContainer(['kernel.debug' => false]); - (new FrameworkExtension())->load([], $container); + (new FrameworkExtension())->load([['http_method_override' => false]], $container); $this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments()); } @@ -1756,21 +1756,21 @@ public function testSessionCookieSecureAuto() public function testRobotsTagListenerIsRegisteredInDebugMode() { $container = $this->createContainer(['kernel.debug' => true]); - (new FrameworkExtension())->load([], $container); + (new FrameworkExtension())->load([['http_method_override' => false]], $container); $this->assertTrue($container->has('disallow_search_engine_index_response_listener'), 'DisallowRobotsIndexingListener should be registered'); $definition = $container->getDefinition('disallow_search_engine_index_response_listener'); $this->assertTrue($definition->hasTag('kernel.event_subscriber'), 'DisallowRobotsIndexingListener should have the correct tag'); $container = $this->createContainer(['kernel.debug' => true]); - (new FrameworkExtension())->load([['disallow_search_engine_index' => false]], $container); + (new FrameworkExtension())->load([['http_method_override' => false, 'disallow_search_engine_index' => false]], $container); $this->assertFalse( $container->has('disallow_search_engine_index_response_listener'), 'DisallowRobotsIndexingListener should not be registered when explicitly disabled' ); $container = $this->createContainer(['kernel.debug' => false]); - (new FrameworkExtension())->load([], $container); + (new FrameworkExtension())->load([['http_method_override' => false]], $container); $this->assertFalse($container->has('disallow_search_engine_index_response_listener'), 'DisallowRobotsIndexingListener should NOT be registered'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index d9f4b1192f45..9c9f12a010ed 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -31,6 +31,7 @@ public function testAssetsCannotHavePathAndUrl() $this->expectException(\LogicException::class); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'assets' => [ 'base_urls' => 'http://cdn.example.com', 'base_path' => '/foo', @@ -44,6 +45,7 @@ public function testAssetPackageCannotHavePathAndUrl() $this->expectException(\LogicException::class); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'assets' => [ 'packages' => [ 'impossible' => [ @@ -62,6 +64,7 @@ public function testWorkflowValidationStateMachine() $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".'); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'workflows' => [ 'article' => [ 'type' => 'state_machine', @@ -90,6 +93,7 @@ public function testRateLimiterWithLockFactory() try { $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'lock' => false, 'rate_limiter' => [ 'with_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour'], @@ -104,6 +108,7 @@ public function testRateLimiterWithLockFactory() $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'lock' => true, 'rate_limiter' => [ 'with_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour'], @@ -119,6 +124,7 @@ public function testRateLimiterLockFactory() { $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ + 'http_method_override' => false, 'rate_limiter' => [ 'without_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour', 'lock_factory' => null], ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml index fec387d87962..87794f637eef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml @@ -2,5 +2,6 @@ imports: - { resource: config.yml } framework: + http_method_override: false annotations: cache: none diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml index 82a5a5422ab7..7ce5cde031c7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false translator: true validation: true serializer: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/config.yml index b991dd593148..a5e861089e67 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/config.yml @@ -12,6 +12,7 @@ services: - name: kernel.cache_clearer framework: + http_method_override: false cache: pools: cache.private_pool: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml index d7733e0e3217..119d9d728078 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml @@ -6,6 +6,7 @@ parameters: env(LIFETIME_EXPRESSION): '13 seconds' framework: + http_method_override: false cache: pools: cache.pool1: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml index e5ec8c4effbc..727cde922727 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml @@ -5,6 +5,7 @@ parameters: env(REDIS_HOST): 'localhost' framework: + http_method_override: false cache: app: cache.adapter.redis default_redis_provider: "redis://%env(REDIS_HOST)%" diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml index 419ee07a0aba..172508c0208a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml @@ -18,6 +18,7 @@ services: provider: cache.test_redis_connection framework: + http_method_override: false cache: pools: cache.pool1: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml index 6dba635a1555..6793268174bc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false secret: '%secret%' default_locale: '%env(LOCALE)%' enabled_locales: ['%env(LOCALE)%'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml index be0eab4d5645..3efa5f950450 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false esi: true ssi: true fragments: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml index 16fc81dd268d..b22016f1e4e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml @@ -3,6 +3,7 @@ imports: - { resource: services.yml } framework: + http_method_override: false fragments: ~ twig: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Mailer/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Mailer/config.yml index b464a41a0d85..2ea7269e629a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Mailer/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Mailer/config.yml @@ -3,6 +3,7 @@ imports: - { resource: services.yml } framework: + http_method_override: false mailer: dsn: 'null://null' envelope: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/config.yml index 12ce67e548ea..ca38aa1aeef5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false profiler: enabled: true collect: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ProfilerCollectParameter/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ProfilerCollectParameter/config.yml index 67360dd32168..67dbec31f194 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ProfilerCollectParameter/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ProfilerCollectParameter/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false profiler: enabled: true collect: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml index 3721de1cac58..5c3c7e132339 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ../config/default.yml } framework: + http_method_override: false serializer: enabled: true default_context: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Slugger/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Slugger/config.yml index 669edf566761..1af9cd9bd32c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Slugger/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Slugger/config.yml @@ -3,6 +3,7 @@ imports: - { resource: services.yml } framework: + http_method_override: false secret: '%secret%' default_locale: '%env(LOCALE)%' enabled_locales: ['%env(LOCALE)%'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/config.yml index 84af2df66271..472c4cdcc02d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/config.yml @@ -3,4 +3,5 @@ imports: - { resource: services.yml } framework: + http_method_override: false test: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/test_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/test_disabled.yml index 6f1b62e4a7a2..6f75b77e7cbb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/test_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TestServiceContainer/test_disabled.yml @@ -3,4 +3,5 @@ imports: - { resource: services.yml } framework: + http_method_override: false test: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TransDebug/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TransDebug/config.yml index 1cd6417b937b..5ca63a12b8ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TransDebug/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TransDebug/config.yml @@ -3,6 +3,7 @@ imports: - { resource: services.yml } framework: + http_method_override: false secret: '%secret%' default_locale: '%env(LOCALE)%' enabled_locales: ['%env(LOCALE)%'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_disabled.yml index 352c1451e350..5e6428618b3e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_disabled.yml @@ -2,5 +2,6 @@ imports: - { resource: "../config/default.yml" } framework: + http_method_override: false uid: enabled: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_enabled.yml index f3139be1d19e..f6d1682c99eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Uid/config_enabled.yml @@ -2,4 +2,5 @@ imports: - { resource: "../config/default.yml" } framework: + http_method_override: false uid: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml index c4087e32f585..e13e9c1c3c78 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: test router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml", utf8: true } validation: { enabled: true, enable_annotations: true } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php index d9dd700efd92..36ba1df088a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php @@ -83,6 +83,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load { $c->register('logger', NullLogger::class); $c->loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => '$ecret', 'router' => ['utf8' => true], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index fff93fc65a8e..64fef6e405c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -120,6 +120,7 @@ public function helloAction(): Response protected function configureContainer(ContainerConfigurator $c): void { $c->extension('framework', [ + 'http_method_override' => false, 'router' => ['utf8' => true], ]); $c->services()->set('logger', NullLogger::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php index 122f73cd4ead..d3aaeb6d387f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php @@ -100,6 +100,6 @@ protected function configureContainer(ContainerConfigurator $c): void ->factory([$this, 'createHalloween']) ->arg('$halloween', '%halloween%'); - $c->extension('framework', ['router' => ['utf8' => true]]); + $c->extension('framework', ['http_method_override' => false, 'router' => ['utf8' => true]]); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php index e9dfde9344fc..bc4d9fe8876b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php @@ -146,7 +146,7 @@ private function createContainer($sessionStorageOptions) ]; $ext = new FrameworkExtension(); - $ext->load(['framework' => ['csrf_protection' => false, 'router' => ['resource' => 'dummy', 'utf8' => true]]], $container); + $ext->load(['framework' => ['http_method_override' => false, 'csrf_protection' => false, 'router' => ['resource' => 'dummy', 'utf8' => true]]], $container); $ext = new SecurityExtension(); $ext->load($config, $container); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Authenticator/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Authenticator/config.yml index 9bf5d2aa8201..a6adcfd0c775 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Authenticator/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Authenticator/config.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: test router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml", utf8: true } test: ~ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml index 758364eaed24..a613f5f24ca7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: test router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml", utf8: true } validation: { enabled: true, enable_annotations: true } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml index 4a8cacb279b1..2c80b9383bb2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml @@ -2,6 +2,7 @@ imports: - { resource: ./../config/framework.yml } framework: + http_method_override: false serializer: ~ security: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/legacy_config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/legacy_config.yml index d0d03c914c48..022263a978e6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/legacy_config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/legacy_config.yml @@ -2,6 +2,7 @@ imports: - { resource: ./../config/framework.yml } framework: + http_method_override: false serializer: ~ security: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMe/stateless_config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMe/stateless_config.yml index cf9102da35a0..31053f856373 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMe/stateless_config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMe/stateless_config.yml @@ -3,6 +3,7 @@ imports: - { resource: ./config_session.yml } framework: + http_method_override: false session: cookie_secure: auto cookie_samesite: lax diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/login_throttling.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/login_throttling.yml index fa94d30dc00c..5f22f41780cd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/login_throttling.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/login_throttling.yml @@ -2,6 +2,7 @@ imports: - { resource: ./base_config.yml } framework: + http_method_override: false lock: ~ rate_limiter: ~ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml index 55186cd76bd3..a86c94455264 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml @@ -1,4 +1,5 @@ framework: + http_method_override: false secret: test router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml", utf8: true } validation: { enabled: true, enable_annotations: true } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php index b571d1cc7609..691430ead578 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php @@ -64,6 +64,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(function (ContainerBuilder $container) { $container ->loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => '$ecret', 'form' => ['enabled' => false], ]) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php index 8078b0986f68..7ec3cbfd72ea 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php @@ -51,6 +51,7 @@ protected function configureRoutes(RoutingConfigurator $routes): void protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void { $containerBuilder->loadFromExtension('framework', [ + 'http_method_override' => false, 'secret' => 'foo-secret', 'profiler' => ['only_exceptions' => false], 'session' => ['storage_factory_id' => 'session.storage.factory.mock_file'], From bb378260e85db6e3d57745647f40db4f4755ae0a Mon Sep 17 00:00:00 2001 From: HypeMC Date: Thu, 21 Apr 2022 08:40:46 +0200 Subject: [PATCH 42/60] [Routing] Fix changelog & deprecation message for #46042 --- UPGRADE-6.1.md | 5 +++++ UPGRADE-6.2.md | 7 ------- src/Symfony/Component/Routing/CHANGELOG.md | 8 ++------ src/Symfony/Component/Routing/Matcher/UrlMatcher.php | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) delete mode 100644 UPGRADE-6.2.md diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md index ee3b5bad5cfd..a3811cb502b9 100644 --- a/UPGRADE-6.1.md +++ b/UPGRADE-6.1.md @@ -32,6 +32,11 @@ HttpKernel * Deprecate StreamedResponseListener, it's not needed anymore +Routing +------- + + * Add argument `$routeParameters` to `UrlMatcher::handleRouteRequirements()` + Serializer ---------- diff --git a/UPGRADE-6.2.md b/UPGRADE-6.2.md deleted file mode 100644 index 4dc684cab8f7..000000000000 --- a/UPGRADE-6.2.md +++ /dev/null @@ -1,7 +0,0 @@ -UPGRADE FROM 6.1 to 6.2 -======================= - -Routing -------- - - * Add argument `$routeParameters` to `UrlMatcher::handleRouteRequirements()` diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 21371e710b0b..62e7cd25f0dc 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -1,12 +1,6 @@ CHANGELOG ========= -6.2 ---- - - * Add `params` variable to condition expression - * Deprecate not passing route parameters as the fourth argument to `UrlMatcher::handleRouteRequirements()` - 6.1 --- @@ -16,6 +10,8 @@ CHANGELOG * Already encoded slashes are not decoded nor double-encoded anymore when generating URLs (query parameters) * Add `EnumRequirement` to help generate route requirements from a `\BackedEnum` * Add `Requirement`, a collection of universal regular-expression constants to use as route parameter requirements + * Add `params` variable to condition expression + * Deprecate not passing route parameters as the fourth argument to `UrlMatcher::handleRouteRequirements()` 5.3 --- diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index b077c0bc3eb7..1a0a9a760136 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -225,7 +225,7 @@ protected function getAttributes(Route $route, string $name, array $attributes): protected function handleRouteRequirements(string $pathinfo, string $name, Route $route/*, array $routeParameters*/): array { if (\func_num_args() < 4) { - trigger_deprecation('symfony/routing', '6.2', 'The "%s()" method will have a new "array $routeParameters" argument in version 7.0, not defining it is deprecated.', __METHOD__); + trigger_deprecation('symfony/routing', '6.1', 'The "%s()" method will have a new "array $routeParameters" argument in version 7.0, not defining it is deprecated.', __METHOD__); $routeParameters = []; } else { $routeParameters = func_get_arg(3); From 9d0054dedd3982908e2ff979046b55ddef9d96be Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 21 Apr 2022 09:22:34 +0200 Subject: [PATCH 43/60] Use mb_convert_encoding instead of utf8_decode --- .../HttpFoundation/Tests/BinaryFileResponseTest.php | 2 +- .../Translation/Tests/Loader/XliffFileLoaderTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index bc3e67a0b650..f88c8a48df1a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -71,7 +71,7 @@ public function testSetContentDispositionGeneratesSafeFallbackFilenameForWrongly { $response = new BinaryFileResponse(__FILE__); - $iso88591EncodedFilename = utf8_decode('föö.html'); + $iso88591EncodedFilename = mb_convert_encoding('föö.html', 'ISO-8859-1', 'UTF-8'); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $iso88591EncodedFilename); // the parameter filename* is invalid in this case (rawurldecode('f%F6%F6') does not provide a UTF-8 string but an ISO-8859-1 encoded one) diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index 164082982ce9..99fcb4588df7 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -88,12 +88,12 @@ public function testEncoding() $loader = new XliffFileLoader(); $catalogue = $loader->load(__DIR__.'/../fixtures/encoding.xlf', 'en', 'domain1'); - $this->assertEquals(utf8_decode('föö'), $catalogue->get('bar', 'domain1')); - $this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1')); + $this->assertEquals(mb_convert_encoding('föö', 'ISO-8859-1', 'UTF-8'), $catalogue->get('bar', 'domain1')); + $this->assertEquals(mb_convert_encoding('bär', 'ISO-8859-1', 'UTF-8'), $catalogue->get('foo', 'domain1')); $this->assertEquals( [ 'source' => 'foo', - 'notes' => [['content' => utf8_decode('bäz')]], + 'notes' => [['content' => mb_convert_encoding('bäz', 'ISO-8859-1', 'UTF-8')]], 'id' => '1', 'file' => [ 'original' => 'file.ext', From c5880a20e53c360cb99af07401a34542b69e3aa6 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 21 Apr 2022 12:29:03 +0200 Subject: [PATCH 44/60] [HttpClient][Translation][Workflow] [Service] Exclude tests from classmaps --- src/Symfony/Component/Workflow/composer.json | 5 ++++- src/Symfony/Contracts/HttpClient/composer.json | 5 ++++- src/Symfony/Contracts/Service/composer.json | 5 ++++- src/Symfony/Contracts/Translation/composer.json | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index eaa9b4607b3f..6b23eeb31370 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -34,7 +34,10 @@ "symfony/event-dispatcher": "<5.4" }, "autoload": { - "psr-4": { "Symfony\\Component\\Workflow\\": "" } + "psr-4": { "Symfony\\Component\\Workflow\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "minimum-stability": "dev" } diff --git a/src/Symfony/Contracts/HttpClient/composer.json b/src/Symfony/Contracts/HttpClient/composer.json index 4e877e5264f7..0a99ad5e72bf 100644 --- a/src/Symfony/Contracts/HttpClient/composer.json +++ b/src/Symfony/Contracts/HttpClient/composer.json @@ -22,7 +22,10 @@ "symfony/http-client-implementation": "" }, "autoload": { - "psr-4": { "Symfony\\Contracts\\HttpClient\\": "" } + "psr-4": { "Symfony\\Contracts\\HttpClient\\": "" }, + "exclude-from-classmap": [ + "/Test/" + ] }, "minimum-stability": "dev", "extra": { diff --git a/src/Symfony/Contracts/Service/composer.json b/src/Symfony/Contracts/Service/composer.json index a4ff0861d547..e7e4a64df08a 100644 --- a/src/Symfony/Contracts/Service/composer.json +++ b/src/Symfony/Contracts/Service/composer.json @@ -26,7 +26,10 @@ "symfony/service-implementation": "" }, "autoload": { - "psr-4": { "Symfony\\Contracts\\Service\\": "" } + "psr-4": { "Symfony\\Contracts\\Service\\": "" }, + "exclude-from-classmap": [ + "/Test/" + ] }, "minimum-stability": "dev", "extra": { diff --git a/src/Symfony/Contracts/Translation/composer.json b/src/Symfony/Contracts/Translation/composer.json index d078be8cf7f5..5240ed0f9d06 100644 --- a/src/Symfony/Contracts/Translation/composer.json +++ b/src/Symfony/Contracts/Translation/composer.json @@ -22,7 +22,10 @@ "symfony/translation-implementation": "" }, "autoload": { - "psr-4": { "Symfony\\Contracts\\Translation\\": "" } + "psr-4": { "Symfony\\Contracts\\Translation\\": "" }, + "exclude-from-classmap": [ + "/Test/" + ] }, "minimum-stability": "dev", "extra": { From 064ee4c1a910a496e7ebff8be7a46c1a4dcbaeeb Mon Sep 17 00:00:00 2001 From: Maxime Pinot Date: Fri, 22 Apr 2022 10:06:46 +0200 Subject: [PATCH 45/60] Remove useless condition --- src/Symfony/Component/Form/Form.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index f404aece2557..fc2b3fdb66f0 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -818,10 +818,6 @@ public function add(FormInterface|string $child, string $type = null, array $opt $child = (string) $child; - if (null !== $type && !\is_string($type)) { - throw new UnexpectedTypeException($type, 'string or null'); - } - // Never initialize child forms automatically $options['auto_initialize'] = false; From a5cc1e1fd8a40eee3b18d9b0c2d01ed95a5db795 Mon Sep 17 00:00:00 2001 From: Pavel Golovin Date: Fri, 22 Apr 2022 19:57:09 +0300 Subject: [PATCH 46/60] Modify processing of uploaded files to be compatible with PHP 8.1 Remove full_path from keys before check Keep logic the same as in src/Symfony/Component/HttpFoundation/FileBag.php --- src/Symfony/Component/Form/NativeRequestHandler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Form/NativeRequestHandler.php b/src/Symfony/Component/Form/NativeRequestHandler.php index 6b18df44a165..b9d0c879caae 100644 --- a/src/Symfony/Component/Form/NativeRequestHandler.php +++ b/src/Symfony/Component/Form/NativeRequestHandler.php @@ -198,6 +198,8 @@ private static function fixPhpFilesArray($data) return $data; } + // Remove extra key added by PHP 8.1. + unset($data['full_path']); $keys = array_keys($data); sort($keys); From 68f309b6782057d1eeb8e9ab5c397e8f8949be8b Mon Sep 17 00:00:00 2001 From: Sergey Belyshkin Date: Wed, 30 Mar 2022 18:52:37 +0700 Subject: [PATCH 47/60] [Cache] Optimize caching of tags --- .../Cache/Adapter/TagAwareAdapter.php | 36 +++++++++---------- .../Tests/Adapter/TagAwareAdapterTest.php | 14 ++++---- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 7e7395b71281..732d02429098 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -39,7 +39,6 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac use LoggerAwareTrait; public const TAGS_PREFIX = "\0tags\0"; - private const MAX_NUMBER_OF_KNOWN_TAG_VERSIONS = 1000; private array $deferred = []; private AdapterInterface $pool; @@ -79,8 +78,7 @@ static function (array $items, array $itemTags) { ); self::$setTagVersions ??= \Closure::bind( static function (array $items, array $tagVersions) { - $now = null; - foreach ($items as $key => $item) { + foreach ($items as $item) { $item->newMetadata[CacheItem::METADATA_TAGS] = array_intersect_key($tagVersions, $item->newMetadata[CacheItem::METADATA_TAGS] ?? []); } }, @@ -343,14 +341,16 @@ public function __destruct() private function getTagVersions(array $tagsByKey, bool $persistTags): array { $tagVersions = []; - $fetchTagVersions = false; + $fetchTagVersions = $persistTags; foreach ($tagsByKey as $tags) { $tagVersions += $tags; - + if ($fetchTagVersions) { + continue; + } foreach ($tags as $tag => $version) { if ($tagVersions[$tag] !== $version) { - unset($this->knownTagVersions[$tag]); + $fetchTagVersions = true; } } } @@ -364,14 +364,10 @@ private function getTagVersions(array $tagsByKey, bool $persistTags): array foreach ($tagVersions as $tag => $version) { $tags[$tag.static::TAGS_PREFIX] = $tag; $knownTagVersion = $this->knownTagVersions[$tag] ?? [0, null]; - if ($fetchTagVersions || $knownTagVersion[1] !== $version || $now - $knownTagVersion[0] >= $this->knownTagVersionsTtl) { - // reuse previously fetched tag versions up to the ttl + if ($fetchTagVersions || $now > $knownTagVersion[0] || $knownTagVersion[1] !== $version) { + // reuse previously fetched tag versions until the expiration $fetchTagVersions = true; } - unset($this->knownTagVersions[$tag]); // For LRU tracking - if ([0, null] !== $knownTagVersion) { - $this->knownTagVersions[$tag] = $knownTagVersion; - } } if (!$fetchTagVersions) { @@ -380,20 +376,24 @@ private function getTagVersions(array $tagsByKey, bool $persistTags): array $newTags = []; $newVersion = null; + $expiration = $now + $this->knownTagVersionsTtl; foreach ($this->tags->getItems(array_keys($tags)) as $tag => $version) { - if (!$version->isHit()) { + unset($this->knownTagVersions[$tag = $tags[$tag]]); // update FIFO + if (null !== $tagVersions[$tag] = $version->get()) { + $this->knownTagVersions[$tag] = [$expiration, $tagVersions[$tag]]; + } elseif ($persistTags) { $newTags[$tag] = $version->set($newVersion ??= random_bytes(6)); + $tagVersions[$tag] = $newVersion; + $this->knownTagVersions[$tag] = [$expiration, $newVersion]; } - $tagVersions[$tag = $tags[$tag]] = $version->get(); - $this->knownTagVersions[$tag] = [$now, $tagVersions[$tag]]; } - if ($newTags && $persistTags) { + if ($newTags) { (self::$saveTags)($this->tags, $newTags); } - if (\count($this->knownTagVersions) > $maxTags = max(self::MAX_NUMBER_OF_KNOWN_TAG_VERSIONS, \count($newTags) << 1)) { - array_splice($this->knownTagVersions, 0, $maxTags >> 1); + while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions)][0] ?? \INF)) { + unset($this->knownTagVersions[$tag]); } return $tagVersions; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index 5d6c52892b45..c242c0dadaa3 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\MockObject\MockObject; -use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -67,15 +66,18 @@ public function testKnownTagVersionsTtl() $pool->save($item); $this->assertTrue($pool->getItem('foo')->isHit()); - $this->assertTrue($pool->getItem('foo')->isHit()); - sleep(20); + $tagsPool->deleteItem('baz'.TagAwareAdapter::TAGS_PREFIX); // tag invalidation - $this->assertTrue($pool->getItem('foo')->isHit()); + $this->assertTrue($pool->getItem('foo')->isHit()); // known tag version is used - sleep(5); + sleep(10); - $this->assertTrue($pool->getItem('foo')->isHit()); + $this->assertTrue($pool->getItem('foo')->isHit()); // known tag version is still used + + sleep(1); + + $this->assertFalse($pool->getItem('foo')->isHit()); // known tag version has expired } public function testInvalidateTagsWithArrayAdapter() From 33f8496ecd3fa8416f5b206557e048e7ae134500 Mon Sep 17 00:00:00 2001 From: Sergey Belyshkin Date: Fri, 22 Apr 2022 21:28:08 +0700 Subject: [PATCH 48/60] [Cache] Prevent fatal errors on php 8 when running concurrently with TagAwareAdapter v6.1 --- .../Cache/Adapter/TagAwareAdapter.php | 19 +++- .../Tests/Adapter/TagAwareAdapterTest.php | 105 ++++++++++++++++++ 2 files changed, 118 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index cd96d2969b9a..e72c38599567 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -177,9 +177,11 @@ public function hasItem($key) } foreach ($this->getTagVersions([$itemTags]) as $tag => $version) { - if ($itemTags[$tag] !== $version && 1 !== $itemTags[$tag] - $version) { - return false; + if ($itemTags[$tag] === $version || \is_int($itemTags[$tag]) && \is_int($version) && 1 === $itemTags[$tag] - $version) { + continue; } + + return false; } return true; @@ -366,10 +368,11 @@ private function generateItems(iterable $items, array $tagKeys) foreach ($itemTags as $key => $tags) { foreach ($tags as $tag => $version) { - if ($tagVersions[$tag] !== $version && 1 !== $version - $tagVersions[$tag]) { - unset($itemTags[$key]); - continue 2; + if ($tagVersions[$tag] === $version || \is_int($version) && \is_int($tagVersions[$tag]) && 1 === $version - $tagVersions[$tag]) { + continue; } + unset($itemTags[$key]); + continue 2; } } $tagVersions = $tagKeys = null; @@ -408,7 +411,7 @@ private function getTagVersions(array $tagsByKey, array &$invalidatedTags = []) $tags = []; foreach ($tagVersions as $tag => $version) { $tags[$tag.static::TAGS_PREFIX] = $tag; - if ($fetchTagVersions || !isset($this->knownTagVersions[$tag])) { + if ($fetchTagVersions || !isset($this->knownTagVersions[$tag]) || !\is_int($version)) { $fetchTagVersions = true; continue; } @@ -430,6 +433,10 @@ private function getTagVersions(array $tagsByKey, array &$invalidatedTags = []) if (isset($invalidatedTags[$tag])) { $invalidatedTags[$tag] = $version->set(++$tagVersions[$tag]); } + if (!\is_int($tagVersions[$tag])) { + unset($this->knownTagVersions[$tag]); + continue; + } $this->knownTagVersions[$tag] = [$now, $tagVersions[$tag]]; } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index 17913f980be7..dfb2a10e6821 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -234,4 +234,109 @@ private function getNonPruneableMock(): AdapterInterface { return $this->createMock(AdapterInterface::class); } + + /** + * @doesNotPerformAssertions + */ + public function testToleranceForStringsAsTagVersionsCase1() + { + $pool = $this->createCachePool(); + $adapter = new FilesystemAdapter(); + + $itemKey = 'foo'; + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set("\x00abc\xff")); + $item = $pool->getItem($itemKey); + $pool->save($item->tag('bar')); + $pool->hasItem($itemKey); + $pool->getItem($itemKey); + } + + /** + * @doesNotPerformAssertions + */ + public function testToleranceForStringsAsTagVersionsCase2() + { + $pool = $this->createCachePool(); + $adapter = new FilesystemAdapter(); + + $itemKey = 'foo'; + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set("\x00abc\xff")); + $item = $pool->getItem($itemKey); + $pool->save($item->tag('bar')); + sleep(100); + $pool->getItem($itemKey); + $pool->hasItem($itemKey); + } + + /** + * @doesNotPerformAssertions + */ + public function testToleranceForStringsAsTagVersionsCase3() + { + $pool = $this->createCachePool(); + $adapter = new FilesystemAdapter(); + + $itemKey = 'foo'; + $adapter->deleteItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $item = $pool->getItem($itemKey); + $pool->save($item->tag('bar')); + $pool->getItem($itemKey); + + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set("\x00abc\xff")); + + $pool->hasItem($itemKey); + $pool->getItem($itemKey); + sleep(100); + $pool->getItem($itemKey); + $pool->hasItem($itemKey); + } + + /** + * @doesNotPerformAssertions + */ + public function testToleranceForStringsAsTagVersionsCase4() + { + $pool = $this->createCachePool(); + $adapter = new FilesystemAdapter(); + + $itemKey = 'foo'; + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set('abcABC')); + + $item = $pool->getItem($itemKey); + $pool->save($item->tag('bar')); + + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set('001122')); + + $pool->invalidateTags(['bar']); + $pool->getItem($itemKey); + } + + /** + * @doesNotPerformAssertions + */ + public function testToleranceForStringsAsTagVersionsCase5() + { + $pool = $this->createCachePool(); + $pool2 = $this->createCachePool(); + $adapter = new FilesystemAdapter(); + + $itemKey1 = 'foo'; + $item = $pool->getItem($itemKey1); + $pool->save($item->tag('bar')); + + $tag = $adapter->getItem('bar'.TagAwareAdapter::TAGS_PREFIX); + $adapter->save($tag->set('abcABC')); + + $itemKey2 = 'baz'; + $item = $pool2->getItem($itemKey2); + $pool2->save($item->tag('bar')); + foreach ($pool->getItems([$itemKey1, $itemKey2]) as $item) { + // run generator + } + } } From 4244aa8c891cf241abc87a206e0e51a82f137136 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 25 Apr 2022 10:40:48 -0700 Subject: [PATCH 49/60] Fix dumping enums on PHP 8.2 --- .../FrameworkBundle/Console/Descriptor/Descriptor.php | 10 +++++++--- .../Console/Descriptor/JsonDescriptor.php | 2 +- .../Console/Descriptor/TextDescriptor.php | 2 +- .../Console/Descriptor/XmlDescriptor.php | 2 +- .../Component/VarExporter/Internal/Exporter.php | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index ab77fbf23b0c..d9b97171e163 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -150,6 +150,10 @@ abstract protected function describeCallable($callable, array $options = []); */ protected function formatValue($value): string { + if ($value instanceof \UnitEnum) { + return ltrim(var_export($value, true), '\\'); + } + if (\is_object($value)) { return sprintf('object(%s)', \get_class($value)); } @@ -158,7 +162,7 @@ protected function formatValue($value): string return $value; } - return preg_replace("/\n\s*/s", '', var_export($value, true)); + return preg_replace("/\n\s*/s", '', ltrim(var_export($value, true)), '\\'); } /** @@ -169,7 +173,7 @@ protected function formatValue($value): string protected function formatParameter($value): string { if ($value instanceof \UnitEnum) { - return var_export($value, true); + return ltrim(var_export($value, true), '\\'); } // Recursively search for enum values, so we can replace it @@ -177,7 +181,7 @@ protected function formatParameter($value): string if (\is_array($value)) { array_walk_recursive($value, static function (&$value) { if ($value instanceof \UnitEnum) { - $value = var_export($value, true); + $value = ltrim(var_export($value, true), '\\'); } }); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 0b38ebf31c0f..64841b1a25d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -162,7 +162,7 @@ private function writeData(array $data, array $options) // before json_encode (which will not display anything for \UnitEnum otherwise) array_walk_recursive($data, static function (&$value) { if ($value instanceof \UnitEnum) { - $value = var_export($value, true); + $value = ltrim(var_export($value, true), '\\'); } }); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 3441536ab840..ea1d3a6abec3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -343,7 +343,7 @@ protected function describeContainerDefinition(Definition $definition, array $op } elseif ($argument instanceof Definition) { $argumentsInformation[] = 'Inlined Service'; } elseif ($argument instanceof \UnitEnum) { - $argumentsInformation[] = var_export($argument, true); + $argumentsInformation[] = ltrim(var_export($argument, true), '\\'); } else { $argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 44a79a8fa90b..65e3dbc17b07 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -388,7 +388,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array } } elseif ($argument instanceof \UnitEnum) { $argumentXML->setAttribute('type', 'constant'); - $argumentXML->appendChild(new \DOMText(var_export($argument, true))); + $argumentXML->appendChild(new \DOMText(ltrim(var_export($argument, true), '\\'))); } else { $argumentXML->appendChild(new \DOMText($argument)); } diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 7141b4e6d96c..078359af5530 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -195,12 +195,13 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount public static function export($value, $indent = '') { switch (true) { - case \is_int($value) || \is_float($value) || $value instanceof \UnitEnum: return var_export($value, true); + case \is_int($value) || \is_float($value): return var_export($value, true); case [] === $value: return '[]'; case false === $value: return 'false'; case true === $value: return 'true'; case null === $value: return 'null'; case '' === $value: return "''"; + case $value instanceof \UnitEnum: return ltrim(var_export($value, true), '\\'); } if ($value instanceof Reference) { From 472072eda3f7c4693b5d9a22ce2c305b38446cd2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 25 Apr 2022 14:15:06 -0700 Subject: [PATCH 50/60] [VarDumper] Fix dumping floats on PHP8 --- src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 4ddaf5e74667..2d3bb0138ac3 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -46,8 +46,7 @@ public function __construct($output = null, string $charset = null, int $flags = { $this->flags = $flags; $this->setCharset($charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'); - $this->decimalPoint = localeconv(); - $this->decimalPoint = $this->decimalPoint['decimal_point']; + $this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point']; $this->setOutput($output ?: static::$defaultOutput); if (!$output && \is_string(static::$defaultOutput)) { static::$defaultOutput = $this->outputStream; @@ -122,8 +121,7 @@ public function setIndentPad($pad) */ public function dump(Data $data, $output = null) { - $this->decimalPoint = localeconv(); - $this->decimalPoint = $this->decimalPoint['decimal_point']; + $this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point']; if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) { setlocale(\LC_NUMERIC, 'C'); From 4628ba67b233fe5ac0655ab53f52120dd53600a2 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Mon, 25 Apr 2022 15:42:36 +0200 Subject: [PATCH 51/60] [Config] Improve GlobResource performance --- .../Config/Resource/GlobResource.php | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index 786cff3e5c29..964066cde69e 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -167,28 +167,31 @@ function (\SplFileInfo $file, $path) { throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern)); } - $finder = new Finder(); $regex = Glob::toRegex($this->pattern); if ($this->recursive) { $regex = substr_replace($regex, '(/|$)', -2, 1); } $prefixLen = \strlen($this->prefix); - foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) { - $normalizedPath = str_replace('\\', '/', $path); - if (!preg_match($regex, substr($normalizedPath, $prefixLen)) || !$info->isFile()) { - continue; - } - if ($this->excludedPrefixes) { - do { - if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) { - continue 2; - } - } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath)); - } - yield $path => $info; - } + yield from (new Finder()) + ->followLinks() + ->filter(function (\SplFileInfo $info) use ($regex, $prefixLen, $prefix) { + $normalizedPath = str_replace('\\', '/', $info->getPathname()); + if (!preg_match($regex, substr($normalizedPath, $prefixLen)) || !$info->isFile()) { + return false; + } + if ($this->excludedPrefixes) { + do { + if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) { + return false; + } + } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath)); + } + }) + ->sortByName() + ->in($this->prefix) + ; } private function computeHash(): string From a8fe12ba40fc032558b72cebf8ac345cf6c70989 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 26 Apr 2022 06:08:29 -0700 Subject: [PATCH 52/60] [DependencyInjection] Properly declare #[When] as allowed on functions --- src/Symfony/Component/DependencyInjection/Attribute/When.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Attribute/When.php b/src/Symfony/Component/DependencyInjection/Attribute/When.php index 3114115fd22e..60b7af04b6e2 100644 --- a/src/Symfony/Component/DependencyInjection/Attribute/When.php +++ b/src/Symfony/Component/DependencyInjection/Attribute/When.php @@ -16,7 +16,7 @@ * * @author Nicolas Grekas */ -#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] +#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION | \Attribute::IS_REPEATABLE)] class When { public function __construct( From 18f3978a1b307c2f291479f6d7f48c471a1ddbfd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 26 Apr 2022 06:36:00 -0700 Subject: [PATCH 53/60] Fix a fix --- .../Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index d9b97171e163..5e90f7ba9f8d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -162,7 +162,7 @@ protected function formatValue($value): string return $value; } - return preg_replace("/\n\s*/s", '', ltrim(var_export($value, true)), '\\'); + return preg_replace("/\n\s*/s", '', var_export($value, true)); } /** From b4e202306ab923b04b131fc91ff5650d7b9ded4f Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Tue, 26 Apr 2022 17:26:22 +0200 Subject: [PATCH 54/60] [Serializer] Fine-tune `ContextBuilder::withContext()` --- .../Context/ContextBuilderInterface.php | 31 +++++++++++++++++++ .../Context/ContextBuilderTrait.php | 8 +++-- .../Encoder/CsvEncoderContextBuilder.php | 3 +- .../Encoder/JsonEncoderContextBuilder.php | 3 +- .../Encoder/XmlEncoderContextBuilder.php | 3 +- .../Encoder/YamlEncoderContextBuilder.php | 3 +- .../AbstractNormalizerContextBuilder.php | 3 +- ...tViolationListNormalizerContextBuilder.php | 3 +- .../DateIntervalNormalizerContextBuilder.php | 3 +- .../DateTimeNormalizerContextBuilder.php | 3 +- .../FormErrorNormalizerContextBuilder.php | 3 +- .../ProblemNormalizerContextBuilder.php | 3 +- .../UidNormalizerContextBuilder.php | 3 +- .../UnwrappingDenormalizerContextBuilder.php | 3 +- .../Context/SerializerContextBuilder.php | 2 +- .../Tests/Context/ContextBuilderTraitTest.php | 7 ++++- 16 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 src/Symfony/Component/Serializer/Context/ContextBuilderInterface.php diff --git a/src/Symfony/Component/Serializer/Context/ContextBuilderInterface.php b/src/Symfony/Component/Serializer/Context/ContextBuilderInterface.php new file mode 100644 index 000000000000..4366d07bcb72 --- /dev/null +++ b/src/Symfony/Component/Serializer/Context/ContextBuilderInterface.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Context; + +/** + * Common interface for context builders. + * + * @author Mathias Arlaud + * @author Robin Chalas + */ +interface ContextBuilderInterface +{ + /** + * @param self|array $context + */ + public function withContext(self|array $context): static; + + /** + * @return array + */ + public function toArray(): array; +} diff --git a/src/Symfony/Component/Serializer/Context/ContextBuilderTrait.php b/src/Symfony/Component/Serializer/Context/ContextBuilderTrait.php index 97907d7b5b53..d7ce5becfd41 100644 --- a/src/Symfony/Component/Serializer/Context/ContextBuilderTrait.php +++ b/src/Symfony/Component/Serializer/Context/ContextBuilderTrait.php @@ -30,10 +30,14 @@ protected function with(string $key, mixed $value): static } /** - * @param array $context + * @param ContextBuilderInterface|array $context */ - public function withContext(array $context): static + public function withContext(ContextBuilderInterface|array $context): static { + if ($context instanceof ContextBuilderInterface) { + $context = $context->toArray(); + } + $instance = new static(); $instance->context = array_merge($this->context, $context); diff --git a/src/Symfony/Component/Serializer/Context/Encoder/CsvEncoderContextBuilder.php b/src/Symfony/Component/Serializer/Context/Encoder/CsvEncoderContextBuilder.php index 8a7bedc0476f..0b08bcc1a5cf 100644 --- a/src/Symfony/Component/Serializer/Context/Encoder/CsvEncoderContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Encoder/CsvEncoderContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Encoder; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Encoder\CsvEncoder; use Symfony\Component\Serializer\Exception\InvalidArgumentException; @@ -20,7 +21,7 @@ * * @author Mathias Arlaud */ -final class CsvEncoderContextBuilder +final class CsvEncoderContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Encoder/JsonEncoderContextBuilder.php b/src/Symfony/Component/Serializer/Context/Encoder/JsonEncoderContextBuilder.php index dfb43ac0978a..0ebd7026984e 100644 --- a/src/Symfony/Component/Serializer/Context/Encoder/JsonEncoderContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Encoder/JsonEncoderContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Encoder; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Encoder\JsonDecode; use Symfony\Component\Serializer\Encoder\JsonEncode; @@ -20,7 +21,7 @@ * * @author Mathias Arlaud */ -final class JsonEncoderContextBuilder +final class JsonEncoderContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Encoder/XmlEncoderContextBuilder.php b/src/Symfony/Component/Serializer/Context/Encoder/XmlEncoderContextBuilder.php index d8273a722903..3f8e92f4e21c 100644 --- a/src/Symfony/Component/Serializer/Context/Encoder/XmlEncoderContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Encoder/XmlEncoderContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Encoder; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Encoder\XmlEncoder; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class XmlEncoderContextBuilder +final class XmlEncoderContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Encoder/YamlEncoderContextBuilder.php b/src/Symfony/Component/Serializer/Context/Encoder/YamlEncoderContextBuilder.php index aa8e554b7bcd..81f6ad90d852 100644 --- a/src/Symfony/Component/Serializer/Context/Encoder/YamlEncoderContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Encoder/YamlEncoderContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Encoder; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Encoder\YamlEncoder; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class YamlEncoderContextBuilder +final class YamlEncoderContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php index 4d65948a8c10..f494f060ac00 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; @@ -20,7 +21,7 @@ * * @author Mathias Arlaud */ -abstract class AbstractNormalizerContextBuilder +abstract class AbstractNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/ConstraintViolationListNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/ConstraintViolationListNormalizerContextBuilder.php index 41dec70d455c..fd1d7c4f5dee 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/ConstraintViolationListNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/ConstraintViolationListNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class ConstraintViolationListNormalizerContextBuilder +final class ConstraintViolationListNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php index 4f5558be5736..98636577a6aa 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class DateIntervalNormalizerContextBuilder +final class DateIntervalNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php index 8e51bf41973d..99517afb1d8d 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; @@ -20,7 +21,7 @@ * * @author Mathias Arlaud */ -final class DateTimeNormalizerContextBuilder +final class DateTimeNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php index deaf5c2a87cf..4cd2ddb88449 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Normalizer\FormErrorNormalizer; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class FormErrorNormalizerContextBuilder +final class FormErrorNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php index ab448f36181a..b525a91adae7 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Normalizer\ProblemNormalizer; @@ -19,7 +20,7 @@ * * @author Mathias Arlaud */ -final class ProblemNormalizerContextBuilder +final class ProblemNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/UidNormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/UidNormalizerContextBuilder.php index c7386d047690..1d889e502526 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/UidNormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/UidNormalizerContextBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Context\Normalizer; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\UidNormalizer; @@ -20,7 +21,7 @@ * * @author Mathias Arlaud */ -final class UidNormalizerContextBuilder +final class UidNormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php b/src/Symfony/Component/Serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php index c09e6df04ea6..f06f6ac77ba5 100644 --- a/src/Symfony/Component/Serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php @@ -13,6 +13,7 @@ use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException; use Symfony\Component\PropertyAccess\PropertyPath; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer; @@ -22,7 +23,7 @@ * * @author Mathias Arlaud */ -final class UnwrappingDenormalizerContextBuilder +final class UnwrappingDenormalizerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Context/SerializerContextBuilder.php b/src/Symfony/Component/Serializer/Context/SerializerContextBuilder.php index 48ea999ecdc8..a6359be98f6d 100644 --- a/src/Symfony/Component/Serializer/Context/SerializerContextBuilder.php +++ b/src/Symfony/Component/Serializer/Context/SerializerContextBuilder.php @@ -19,7 +19,7 @@ * * @author Mathias Arlaud */ -final class SerializerContextBuilder +final class SerializerContextBuilder implements ContextBuilderInterface { use ContextBuilderTrait; diff --git a/src/Symfony/Component/Serializer/Tests/Context/ContextBuilderTraitTest.php b/src/Symfony/Component/Serializer/Tests/Context/ContextBuilderTraitTest.php index 4c25e17c0c7a..17ad231a032a 100644 --- a/src/Symfony/Component/Serializer/Tests/Context/ContextBuilderTraitTest.php +++ b/src/Symfony/Component/Serializer/Tests/Context/ContextBuilderTraitTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Serializer\Tests\Context; use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Context\ContextBuilderInterface; use Symfony\Component\Serializer\Context\ContextBuilderTrait; /** @@ -21,13 +22,17 @@ class ContextBuilderTraitTest extends TestCase { public function testWithContext() { - $contextBuilder = new class() { + $contextBuilder = new class() implements ContextBuilderInterface { use ContextBuilderTrait; }; $context = $contextBuilder->withContext(['foo' => 'bar'])->toArray(); $this->assertSame(['foo' => 'bar'], $context); + + $withContextBuilderObject = $contextBuilder->withContext($contextBuilder->withContext(['foo' => 'bar']))->toArray(); + + $this->assertSame(['foo' => 'bar'], $withContextBuilderObject); } public function testWith() From 1f15941c0810c5b25f91c8a0b9456c23c853cfe3 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Tue, 26 Apr 2022 16:20:46 +0200 Subject: [PATCH 55/60] [Messenger] Add PostgreSqlConnection tests --- .../DoctrinePostgreSqlIntegrationTest.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php new file mode 100644 index 000000000000..a53505f6f2d1 --- /dev/null +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport; + +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Schema\AbstractSchemaManager; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage; +use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection; + +/** + * @requires extension pdo_pgsql + * @group integration + */ +class DoctrinePostgreSqlIntegrationTest extends TestCase +{ + /** @var Connection */ + private $driverConnection; + /** @var PostgreSqlConnection */ + private $connection; + + protected function setUp(): void + { + if (!$host = getenv('POSTGRES_HOST')) { + $this->markTestSkipped('Missing POSTGRES_HOST env variable'); + } + + $this->driverConnection = DriverManager::getConnection(['url' => "pgsql://postgres:password@$host"]); + $this->connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $this->driverConnection); + $this->connection->setup(); + } + + protected function tearDown(): void + { + $this->createSchemaManager()->dropTable('queue_table'); + $this->driverConnection->close(); + } + + public function testPostgreSqlConnectionSendAndGet() + { + $this->connection->send('{"message": "Hi"}', ['type' => DummyMessage::class]); + + $encoded = $this->connection->get(); + $this->assertEquals('{"message": "Hi"}', $encoded['body']); + $this->assertEquals(['type' => DummyMessage::class], $encoded['headers']); + + $this->assertNull($this->connection->get()); + } + + private function createSchemaManager(): AbstractSchemaManager + { + return method_exists($this->driverConnection, 'createSchemaManager') + ? $this->driverConnection->createSchemaManager() + : $this->driverConnection->getSchemaManager(); + } +} From 635e995a0a36786ee99bc27e6dff95948c42581d Mon Sep 17 00:00:00 2001 From: zenas1210 Date: Sun, 24 Apr 2022 17:34:28 +0300 Subject: [PATCH 56/60] [Mailer] Restore X-Transport after failure --- .../Mailer/Tests/Transport/TransportsTest.php | 24 +++++++++++++++++++ .../Component/Mailer/Transport/Transports.php | 8 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mailer/Tests/Transport/TransportsTest.php b/src/Symfony/Component/Mailer/Tests/Transport/TransportsTest.php index 10d46ca846b4..e50db434ffc0 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/TransportsTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/TransportsTest.php @@ -64,4 +64,28 @@ public function testTransportDoesNotExist() $this->expectExceptionMessage('The "foobar" transport does not exist (available transports: "foo", "bar").'); $transport->send($email); } + + public function testTransportRestoredAfterFailure() + { + $exception = new \Exception(); + + $fooTransport = $this->createMock(TransportInterface::class); + $fooTransport->method('send') + ->willThrowException($exception); + + $transport = new Transports([ + 'foo' => $fooTransport, + ]); + + $headers = (new Headers())->addTextHeader('X-Transport', 'foo'); + $email = new Message($headers, new TextPart('...')); + + $this->expectExceptionObject($exception); + + try { + $transport->send($email); + } finally { + $this->assertSame('foo', $email->getHeaders()->getHeaderBody('X-Transport')); + } + } } diff --git a/src/Symfony/Component/Mailer/Transport/Transports.php b/src/Symfony/Component/Mailer/Transport/Transports.php index c8f7970b32ef..702fc5c784cd 100644 --- a/src/Symfony/Component/Mailer/Transport/Transports.php +++ b/src/Symfony/Component/Mailer/Transport/Transports.php @@ -59,7 +59,13 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa throw new InvalidArgumentException(sprintf('The "%s" transport does not exist (available transports: "%s").', $transport, implode('", "', array_keys($this->transports)))); } - return $this->transports[$transport]->send($message, $envelope); + try { + return $this->transports[$transport]->send($message, $envelope); + } catch (\Throwable $e) { + $headers->addTextHeader('X-Transport', $transport); + + throw $e; + } } public function __toString(): string From 7bc07a526dadc27addfd994a7326962c8f0fddca Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 27 Apr 2022 15:22:47 +0200 Subject: [PATCH 57/60] [Routing] Use the null coalescing operator --- .../Routing/Loader/AnnotationClassLoader.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index de069776bb33..204e9b3341f2 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -150,10 +150,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g return; } - $name = $annot->getName(); - if (null === $name) { - $name = $this->getDefaultRouteName($class, $method); - } + $name = $annot->getName() ?? $this->getDefaultRouteName($class, $method); $name = $globals['name'].$name; $requirements = $annot->getRequirements(); @@ -170,11 +167,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g $schemes = array_merge($globals['schemes'], $annot->getSchemes()); $methods = array_merge($globals['methods'], $annot->getMethods()); - $host = $annot->getHost(); - if (null === $host) { - $host = $globals['host']; - } - + $host = $annot->getHost() ?? $globals['host']; $condition = $annot->getCondition() ?? $globals['condition']; $priority = $annot->getPriority() ?? $globals['priority']; From 49644c69c7bc652d4776837aa1f17366e71e9012 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Mon, 25 Apr 2022 11:38:40 +0200 Subject: [PATCH 58/60] [Routing] Remove variadic constructor signature --- .../Routing/Requirement/EnumRequirement.php | 42 +++++++++++-------- .../Tests/Requirement/EnumRequirementTest.php | 19 ++++++--- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Component/Routing/Requirement/EnumRequirement.php b/src/Symfony/Component/Routing/Requirement/EnumRequirement.php index ba5078cda3f8..2a369845c4eb 100644 --- a/src/Symfony/Component/Routing/Requirement/EnumRequirement.php +++ b/src/Symfony/Component/Routing/Requirement/EnumRequirement.php @@ -15,36 +15,42 @@ final class EnumRequirement implements \Stringable { - /** - * @var string[] - */ - private readonly array $values; + private string $requirement; /** * @template T of \BackedEnum - * @param class-string $enum - * @param T ...$cases + * + * @param class-string|list $cases */ - public function __construct(string $enum, \BackedEnum ...$cases) + public function __construct(string|array $cases = []) { - if (!\is_subclass_of($enum, \BackedEnum::class, true)) { - throw new InvalidArgumentException(sprintf('"%s" is not a \BackedEnum class.', $enum)); - } + if (\is_string($cases)) { + if (!is_subclass_of($cases, \BackedEnum::class, true)) { + throw new InvalidArgumentException(sprintf('"%s" is not a "BackedEnum" class.', $cases)); + } + + $cases = $cases::cases(); + } else { + $class = null; + + foreach ($cases as $case) { + if (!$case instanceof \BackedEnum) { + throw new InvalidArgumentException(sprintf('Case must be a "BackedEnum" instance, "%s" given.', get_debug_type($case))); + } + + $class ??= \get_class($case); - foreach ($cases as $case) { - if (!$case instanceof $enum) { - throw new InvalidArgumentException(sprintf('"%s::%s" is not a case of "%s".', \get_class($case), $case->name, $enum)); + if (!$case instanceof $class) { + throw new InvalidArgumentException(sprintf('"%s::%s" is not a case of "%s".', get_debug_type($case), $case->name, $class)); + } } } - $this->values = array_map( - static fn (\BackedEnum $e): string => $e->value, - $cases ?: $enum::cases(), - ); + $this->requirement = implode('|', array_map(static fn ($e) => preg_quote($e->value), $cases)); } public function __toString(): string { - return implode('|', array_map(preg_quote(...), $this->values)); + return $this->requirement; } } diff --git a/src/Symfony/Component/Routing/Tests/Requirement/EnumRequirementTest.php b/src/Symfony/Component/Routing/Tests/Requirement/EnumRequirementTest.php index 18484c03d142..75613f498557 100644 --- a/src/Symfony/Component/Routing/Tests/Requirement/EnumRequirementTest.php +++ b/src/Symfony/Component/Routing/Tests/Requirement/EnumRequirementTest.php @@ -25,25 +25,33 @@ class EnumRequirementTest extends TestCase public function testNotABackedEnum() { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestUnitEnum" is not a \BackedEnum class.'); + $this->expectExceptionMessage('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestUnitEnum" is not a "BackedEnum" class.'); new EnumRequirement(TestUnitEnum::class); } + public function testCaseNotABackedEnum() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Case must be a "BackedEnum" instance, "string" given.'); + + new EnumRequirement(['wrong']); + } + public function testCaseFromAnotherEnum() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestStringBackedEnum2::Spades" is not a case of "Symfony\Component\Routing\Tests\Fixtures\Enum\TestStringBackedEnum".'); - new EnumRequirement(TestStringBackedEnum::class, TestStringBackedEnum::Diamonds, TestStringBackedEnum2::Spades); + new EnumRequirement([TestStringBackedEnum::Diamonds, TestStringBackedEnum2::Spades]); } /** * @dataProvider provideToString */ - public function testToString(string $expected, string $enum, \BackedEnum ...$cases) + public function testToString(string $expected, string|array $cases = []) { - $this->assertSame($expected, (string) new EnumRequirement($enum, ...$cases)); + $this->assertSame($expected, (string) new EnumRequirement($cases)); } public function provideToString() @@ -51,7 +59,8 @@ public function provideToString() return [ ['hearts|diamonds|clubs|spades', TestStringBackedEnum::class], ['10|20|30|40', TestIntBackedEnum::class], - ['diamonds|spades', TestStringBackedEnum::class, TestStringBackedEnum::Diamonds, TestStringBackedEnum::Spades], + ['diamonds|spades', [TestStringBackedEnum::Diamonds, TestStringBackedEnum::Spades]], + ['diamonds', [TestStringBackedEnum::Diamonds]], ['hearts|diamonds|clubs|spa\|des', TestStringBackedEnum2::class], ]; } From ca6344d22ededcb5ff84434bcf0e52d7fb802f48 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Apr 2022 19:30:19 +0200 Subject: [PATCH 59/60] Update CHANGELOG for 6.1.0-BETA2 --- CHANGELOG-6.1.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG-6.1.md b/CHANGELOG-6.1.md index e8cacc83e621..c6f96fbf1575 100644 --- a/CHANGELOG-6.1.md +++ b/CHANGELOG-6.1.md @@ -7,6 +7,33 @@ in 6.1 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.1.0...v6.1.1 +* 6.1.0-BETA2 (2022-04-27) + + * feature #45282 [Serializer] Support canners in object normalizer (rmikalkenas) + * feature #46157 [Routing] Remove variadic constructor signature (wouterj) + * bug #46154 [Mailer] Restore X-Transport after failure (zenas1210) + * bug #46178 [DependencyInjection] Properly declare #[When] as allowed on functions (nicolas-grekas) + * bug #46171 [VarDumper] Fix dumping floats on PHP8 (nicolas-grekas) + * bug #46170 Fix dumping enums on PHP 8.2 (nicolas-grekas) + * bug #46143 [Cache] Prevent fatal errors on php 8 when running concurrently with TagAwareAdapter v6.1 (sbelyshkin) + * bug #45896 [Cache] Optimize caching of tags (sbelyshkin) + * bug #46149 Modify processing of uploaded files to be compatible with PHP 8.1 (p-golovin) + * feature #46112 [DependencyInjection] Rename `#[InnerService]` to `#[MapDecorated]` (chalasr) + * bug #46125 [FrameworkBundle] Always add CacheCollectorPass (fancyweb) + * feature #45989 [FrameworkBundle] deprecate not setting http_method_override (Tobion) + * feature #46042 [Routing] Add params variable to condition expression (HypeMC) + * feature #46115 [FrameworkBundle] Add support for route attributes in kernel controller methods (dunglas) + * bug #46121 Fix "Notice: Undefined index: headers" in messenger with Oracle (rjd22) + * feature #45834 [DependencyInjection] add AsDecorator class attribute and InnerService parameter attribute (Jean-Beru) + * bug #46106 [String] Fix ansi escape sequences regex (fancyweb) + * feature #46056 [PropertyInfo] Add support for promoted properties in PhpStanExtractor (simPod) + * feature #46047 [Notifier] smsapi - send messages in test mode (Patryk Kozłowski) + * bug #46097 [Routing] fix router base url when default uri has trailing slash (Tobion) + * feature #46052 [TwigBundle] Deprecate option "autoescape", use "autoescape_service[_method]" instead (nicolas-grekas) + * bug #46054 [SecurityBundle] Use config's secret in remember-me signatures (jderusse) + * feature #45528 [Routing] Add Requirement, a collection of universal regular-expressions constants to use as route parameter requirements (fancyweb) + * bug #46051 Don't replace symfony/security-guard (derrabus) + * 6.1.0-BETA1 (2022-04-15) * feature #44798 [FrameworkBundle] Integrate the HtmlSanitizer component (tgalopin, wouterj) From 684274649434bb1d17fbcd37ca28a2c2d5fae1b9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Apr 2022 19:30:23 +0200 Subject: [PATCH 60/60] Update VERSION for 6.1.0-BETA2 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index aafc62dbb01f..89fb8c061707 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.0-DEV'; + public const VERSION = '6.1.0-BETA2'; public const VERSION_ID = 60100; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = 'BETA2'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023';