From a1c153508a4052cd665595f7f3e2214a8e5f7aa0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 24 Jan 2023 15:02:24 +0100 Subject: [PATCH 01/13] Update license years (last time) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 00837045..0138f8f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From fc7442b190693792c7b3f9d639502ddfd0a0c920 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Feb 2023 10:31:13 +0100 Subject: [PATCH 02/13] minor #49253 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` (OskarStark) This PR was merged into the 6.3 branch. Discussion ---------- [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Refs https://github.com/symfony/symfony/pull/49233 | License | MIT | Doc PR | n/a Replaces #49234 Using `Test` suffix is deprecated since PHPUnit 10 Spotted in * https://github.com/symfony/symfony/pull/49233 Commits ------- cb3db968e4 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` --- ...est.php => AbstractBootstrap3HorizontalLayoutTestCase.php} | 2 +- ...ap3LayoutTest.php => AbstractBootstrap3LayoutTestCase.php} | 4 ++-- ...est.php => AbstractBootstrap4HorizontalLayoutTestCase.php} | 2 +- ...ap4LayoutTest.php => AbstractBootstrap4LayoutTestCase.php} | 2 +- ...est.php => AbstractBootstrap5HorizontalLayoutTestCase.php} | 2 +- ...ap5LayoutTest.php => AbstractBootstrap5LayoutTestCase.php} | 2 +- .../Extension/FormExtensionBootstrap3HorizontalLayoutTest.php | 2 +- Tests/Extension/FormExtensionBootstrap3LayoutTest.php | 2 +- .../Extension/FormExtensionBootstrap4HorizontalLayoutTest.php | 2 +- Tests/Extension/FormExtensionBootstrap4LayoutTest.php | 2 +- .../Extension/FormExtensionBootstrap5HorizontalLayoutTest.php | 2 +- Tests/Extension/FormExtensionBootstrap5LayoutTest.php | 2 +- Tests/Extension/FormExtensionDivLayoutTest.php | 4 ++-- Tests/Extension/FormExtensionTableLayoutTest.php | 4 ++-- composer.json | 4 ++-- 15 files changed, 19 insertions(+), 19 deletions(-) rename Tests/Extension/{AbstractBootstrap3HorizontalLayoutTest.php => AbstractBootstrap3HorizontalLayoutTestCase.php} (98%) rename Tests/Extension/{AbstractBootstrap3LayoutTest.php => AbstractBootstrap3LayoutTestCase.php} (99%) rename Tests/Extension/{AbstractBootstrap4HorizontalLayoutTest.php => AbstractBootstrap4HorizontalLayoutTestCase.php} (98%) rename Tests/Extension/{AbstractBootstrap4LayoutTest.php => AbstractBootstrap4LayoutTestCase.php} (99%) rename Tests/Extension/{AbstractBootstrap5HorizontalLayoutTest.php => AbstractBootstrap5HorizontalLayoutTestCase.php} (99%) rename Tests/Extension/{AbstractBootstrap5LayoutTest.php => AbstractBootstrap5LayoutTestCase.php} (99%) diff --git a/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php similarity index 98% rename from Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php index c4874c34..e79b0c31 100644 --- a/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; -abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap3HorizontalLayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testLabelOnForm() { diff --git a/Tests/Extension/AbstractBootstrap3LayoutTest.php b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap3LayoutTest.php rename to Tests/Extension/AbstractBootstrap3LayoutTestCase.php index 80835230..aa52233a 100644 --- a/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php @@ -13,9 +13,9 @@ use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Tests\AbstractLayoutTest; +use Symfony\Component\Form\Tests\AbstractLayoutTestCase; -abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest +abstract class AbstractBootstrap3LayoutTestCase extends AbstractLayoutTestCase { public function testLabelOnForm() { diff --git a/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php similarity index 98% rename from Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php index 1ef14ecf..ce8a7336 100644 --- a/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php @@ -18,7 +18,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap4HorizontalLayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap4LayoutTest.php b/Tests/Extension/AbstractBootstrap4LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap4LayoutTest.php rename to Tests/Extension/AbstractBootstrap4LayoutTestCase.php index 8689df83..e329b5d4 100644 --- a/Tests/Extension/AbstractBootstrap4LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap4LayoutTestCase.php @@ -28,7 +28,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap4LayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php index 863e6a50..ddaa4cdc 100644 --- a/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php @@ -24,7 +24,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5HorizontalLayoutTest extends AbstractBootstrap5LayoutTest +abstract class AbstractBootstrap5HorizontalLayoutTestCase extends AbstractBootstrap5LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap5LayoutTest.php b/Tests/Extension/AbstractBootstrap5LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap5LayoutTest.php rename to Tests/Extension/AbstractBootstrap5LayoutTestCase.php index ebeacf70..25349e14 100644 --- a/Tests/Extension/AbstractBootstrap5LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap5LayoutTestCase.php @@ -36,7 +36,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5LayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap5LayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index a0953a2d..e746a267 100644 --- a/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest +class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index a3a6c751..2b7e186c 100644 --- a/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest +class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index 33e1862a..f95e6784 100644 --- a/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTest +class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index 00fee10e..2d0ca9fa 100644 --- a/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest +class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTestCase { use RuntimeLoaderProvider; /** diff --git a/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index ef924884..d6d2c3c2 100644 --- a/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTest +class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index ed69ca81..94174615 100644 --- a/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -28,7 +28,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTest +class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionDivLayoutTest.php b/Tests/Extension/FormExtensionDivLayoutTest.php index e7991240..6a3ddfe3 100644 --- a/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/Tests/Extension/FormExtensionDivLayoutTest.php @@ -18,12 +18,12 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractDivLayoutTest; +use Symfony\Component\Form\Tests\AbstractDivLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionDivLayoutTest extends AbstractDivLayoutTest +class FormExtensionDivLayoutTest extends AbstractDivLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionTableLayoutTest.php b/Tests/Extension/FormExtensionTableLayoutTest.php index 20b46541..25d595df 100644 --- a/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/Tests/Extension/FormExtensionTableLayoutTest.php @@ -17,12 +17,12 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractTableLayoutTest; +use Symfony\Component\Form\Tests\AbstractTableLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionTableLayoutTest extends AbstractTableLayoutTest +class FormExtensionTableLayoutTest extends AbstractTableLayoutTestCase { use RuntimeLoaderProvider; diff --git a/composer.json b/composer.json index c67b92f7..07275fe4 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "symfony/asset": "^4.4|^5.0|^6.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/form": "^5.3|^6.0", + "symfony/form": "^5.4.21|^6.2.7", "symfony/http-foundation": "^5.3|^6.0", "symfony/http-kernel": "^4.4|^5.0|^6.0", "symfony/intl": "^4.4|^5.0|^6.0", @@ -56,7 +56,7 @@ "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/console": "<5.3", - "symfony/form": "<5.3", + "symfony/form": "<5.4.21|>=6,<6.2.7", "symfony/http-foundation": "<5.3", "symfony/http-kernel": "<4.4", "symfony/translation": "<5.2", From 4ff8d7dfbd190771dc81f9de87ccd7d2017c1db6 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 14 Dec 2022 15:42:16 +0100 Subject: [PATCH 03/13] Migrate to `static` data providers using `rector/rector` --- Tests/AppVariableTest.php | 2 +- Tests/Command/DebugCommandTest.php | 4 ++-- Tests/Command/LintCommandTest.php | 2 +- Tests/Extension/CodeExtensionTest.php | 4 ++-- Tests/Extension/DumpExtensionTest.php | 4 ++-- Tests/Extension/FormExtensionDivLayoutTest.php | 4 ++-- Tests/Extension/HttpFoundationExtensionTest.php | 6 +++--- Tests/Extension/RoutingExtensionTest.php | 2 +- Tests/Extension/SerializerExtensionTest.php | 2 +- Tests/Extension/StopwatchExtensionTest.php | 2 +- Tests/Extension/TranslationExtensionTest.php | 2 +- .../NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php | 2 +- Tests/NodeVisitor/TranslationNodeVisitorTest.php | 2 +- Tests/TokenParser/FormThemeTokenParserTest.php | 2 +- Tests/Translation/TwigExtractorTest.php | 6 +++--- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Tests/AppVariableTest.php b/Tests/AppVariableTest.php index 84e9ea8c..ea3fbfda 100644 --- a/Tests/AppVariableTest.php +++ b/Tests/AppVariableTest.php @@ -43,7 +43,7 @@ public function testDebug($debugFlag) $this->assertEquals($debugFlag, $this->appVariable->getDebug()); } - public function debugDataProvider() + public static function debugDataProvider() { return [ 'debug on' => [true], diff --git a/Tests/Command/DebugCommandTest.php b/Tests/Command/DebugCommandTest.php index 2488a276..45591415 100644 --- a/Tests/Command/DebugCommandTest.php +++ b/Tests/Command/DebugCommandTest.php @@ -84,7 +84,7 @@ public function testDebugTemplateName(array $input, string $output, array $paths $this->assertStringMatchesFormat($output, $tester->getDisplay(true)); } - public function getDebugTemplateNameTestData() + public static function getDebugTemplateNameTestData() { $defaultPaths = [ 'templates/' => null, @@ -315,7 +315,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'name' => [['email'], []]; yield 'option --format' => [['--format', ''], ['text', 'json']]; diff --git a/Tests/Command/LintCommandTest.php b/Tests/Command/LintCommandTest.php index 6a3d640b..a898680f 100644 --- a/Tests/Command/LintCommandTest.php +++ b/Tests/Command/LintCommandTest.php @@ -150,7 +150,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option' => [['--format', ''], ['txt', 'json', 'github']]; } diff --git a/Tests/Extension/CodeExtensionTest.php b/Tests/Extension/CodeExtensionTest.php index 33bb266c..38983cbd 100644 --- a/Tests/Extension/CodeExtensionTest.php +++ b/Tests/Extension/CodeExtensionTest.php @@ -44,7 +44,7 @@ public function testGettingMethodAbbreviation($method, $abbr) $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr); } - public function getClassNameProvider(): array + public static function getClassNameProvider(): array { return [ ['F\Q\N\Foo', 'Foo'], @@ -52,7 +52,7 @@ public function getClassNameProvider(): array ]; } - public function getMethodNameProvider(): array + public static function getMethodNameProvider(): array { return [ ['F\Q\N\Foo::Method', 'Foo::Method()'], diff --git a/Tests/Extension/DumpExtensionTest.php b/Tests/Extension/DumpExtensionTest.php index d0825221..8fe455e5 100644 --- a/Tests/Extension/DumpExtensionTest.php +++ b/Tests/Extension/DumpExtensionTest.php @@ -53,7 +53,7 @@ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) $this->assertSame($expectedDumped, $dumped); } - public function getDumpTags() + public static function getDumpTags() { return [ ['A{% dump %}B', true, 'AB', []], @@ -88,7 +88,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) $this->assertEquals($expectedOutput, $dump); } - public function getDumpArgs() + public static function getDumpArgs() { return [ [[], [], '', false], diff --git a/Tests/Extension/FormExtensionDivLayoutTest.php b/Tests/Extension/FormExtensionDivLayoutTest.php index 6a3ddfe3..3809f3fa 100644 --- a/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/Tests/Extension/FormExtensionDivLayoutTest.php @@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend() ); } - public function isSelectedChoiceProvider() + public static function isSelectedChoiceProvider() { return [ [true, '0', '0'], @@ -150,7 +150,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero() $this->assertSame('
', $html); } - public function isRootFormProvider() + public static function isRootFormProvider() { return [ [true, new FormView()], diff --git a/Tests/Extension/HttpFoundationExtensionTest.php b/Tests/Extension/HttpFoundationExtensionTest.php index ea3bb17b..28ddacd0 100644 --- a/Tests/Extension/HttpFoundationExtensionTest.php +++ b/Tests/Extension/HttpFoundationExtensionTest.php @@ -32,7 +32,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlData() + public static function getGenerateAbsoluteUrlData() { return [ ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], @@ -84,7 +84,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlRequestContextData() + public static function getGenerateAbsoluteUrlRequestContextData() { return [ ['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'], @@ -129,7 +129,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateRelativePath($path)); } - public function getGenerateRelativePathData() + public static function getGenerateRelativePathData() { return [ ['../foo.png', '/foo.png', '/foo/bar.html'], diff --git a/Tests/Extension/RoutingExtensionTest.php b/Tests/Extension/RoutingExtensionTest.php index 5a995c8e..742a74f3 100644 --- a/Tests/Extension/RoutingExtensionTest.php +++ b/Tests/Extension/RoutingExtensionTest.php @@ -34,7 +34,7 @@ public function testEscaping($template, $mustBeEscaped) $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof FilterExpression); } - public function getEscapingTemplates() + public static function getEscapingTemplates() { return [ ['{{ path("foo") }}', false], diff --git a/Tests/Extension/SerializerExtensionTest.php b/Tests/Extension/SerializerExtensionTest.php index ef54ee27..0c36c8c6 100644 --- a/Tests/Extension/SerializerExtensionTest.php +++ b/Tests/Extension/SerializerExtensionTest.php @@ -41,7 +41,7 @@ public function testSerializeFilter(string $template, string $expectedResult) self::assertSame($expectedResult, $twig->render('template', ['object' => new SerializerModelFixture()])); } - public function serializerDataProvider(): \Generator + public static function serializerDataProvider(): \Generator { yield ['{{ object|serialize }}', '{"name":"howdy","title":"fixture"}']; yield ['{{ object|serialize(\'yaml\') }}', '{ name: howdy, title: fixture }']; diff --git a/Tests/Extension/StopwatchExtensionTest.php b/Tests/Extension/StopwatchExtensionTest.php index 65f1bd69..59a39374 100644 --- a/Tests/Extension/StopwatchExtensionTest.php +++ b/Tests/Extension/StopwatchExtensionTest.php @@ -41,7 +41,7 @@ public function testTiming($template, $events) } } - public function getTimingTemplates() + public static function getTimingTemplates() { return [ ['{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'], diff --git a/Tests/Extension/TranslationExtensionTest.php b/Tests/Extension/TranslationExtensionTest.php index 86f50da0..8e7ab4fc 100644 --- a/Tests/Extension/TranslationExtensionTest.php +++ b/Tests/Extension/TranslationExtensionTest.php @@ -61,7 +61,7 @@ public function testTransComplexBody() $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); } - public function getTransTests() + public static function getTransTests() { return [ // trans tag diff --git a/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index cc2b6ef2..25b8166e 100644 --- a/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -76,7 +76,7 @@ public function testNewModuleWithoutDefaultDomainTag(Node $node) $this->assertEquals([[self::$message, null]], $visitor->getMessages()); } - public function getDefaultDomainAssignmentTestData() + public static function getDefaultDomainAssignmentTestData() { return [ [TwigNodeProvider::getTransFilter(self::$message)], diff --git a/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 069914a4..bf073602 100644 --- a/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -51,7 +51,7 @@ public function testMessageExtractionWithInvalidDomainNode() $this->testMessagesExtraction($node, [[$message, TranslationNodeVisitor::UNDEFINED_DOMAIN]]); } - public function getMessagesExtractionTestData() + public static function getMessagesExtractionTestData() { $message = 'new key'; $domain = 'domain'; diff --git a/Tests/TokenParser/FormThemeTokenParserTest.php b/Tests/TokenParser/FormThemeTokenParserTest.php index d4040600..41504050 100644 --- a/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/Tests/TokenParser/FormThemeTokenParserTest.php @@ -40,7 +40,7 @@ public function testCompile($source, $expected) $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); } - public function getTestsForFormTheme() + public static function getTestsForFormTheme() { return [ [ diff --git a/Tests/Translation/TwigExtractorTest.php b/Tests/Translation/TwigExtractorTest.php index 4a8b4d19..060a0578 100644 --- a/Tests/Translation/TwigExtractorTest.php +++ b/Tests/Translation/TwigExtractorTest.php @@ -54,7 +54,7 @@ public function testExtract($template, $messages) } } - public function getExtractData() + public static function getExtractData() { return [ ['{{ "new key" | trans() }}', ['new key' => 'messages']], @@ -102,7 +102,7 @@ public function testExtractSyntaxError($resources, array $messages) $this->assertSame($messages, $catalogue->all()); } - public function resourcesWithSyntaxErrorsProvider(): array + public static function resourcesWithSyntaxErrorsProvider(): array { return [ [__DIR__.'/../Fixtures', ['messages' => ['Hi!' => 'Hi!']]], @@ -133,7 +133,7 @@ public function testExtractWithFiles($resource) $this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages')); } - public function resourceProvider(): array + public static function resourceProvider(): array { $directory = __DIR__.'/../Fixtures/extractor/'; From be307e40903b3ff3e00ce534a6a4add92809eff3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 14 Feb 2023 15:10:14 +0100 Subject: [PATCH 04/13] Fix tests --- Tests/Mime/TemplatedEmailTest.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Tests/Mime/TemplatedEmailTest.php b/Tests/Mime/TemplatedEmailTest.php index 77548fb1..b2101719 100644 --- a/Tests/Mime/TemplatedEmailTest.php +++ b/Tests/Mime/TemplatedEmailTest.php @@ -73,11 +73,9 @@ public function testSymfonySerialize() "html": null, "htmlCharset": null, "attachments": [ - { - "body": "Some Text file", - "name": "test.txt", - "content-type": null, - "inline": false + {%A + "body": "Some Text file",%A + "name": "test.txt",%A } ], "headers": { @@ -111,11 +109,11 @@ public function testSymfonySerialize() ], [new JsonEncoder()]); $serialized = $serializer->serialize($e, 'json', [ObjectNormalizer::IGNORED_ATTRIBUTES => ['cachedBody']]); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); + $this->assertStringMatchesFormat($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n = $serializer->deserialize($serialized, TemplatedEmail::class, 'json'); $serialized = $serializer->serialize($e, 'json', [ObjectNormalizer::IGNORED_ATTRIBUTES => ['cachedBody']]); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); + $this->assertStringMatchesFormat($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n->from('fabien@symfony.com'); $expected->from('fabien@symfony.com'); From a8be6ae396fd668ce83993e9a928494b914ec34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Egyed?= Date: Thu, 16 Feb 2023 01:02:07 +0100 Subject: [PATCH 05/13] [TwigBridge] Fix raw content rendering in HTML notification emails --- Resources/views/Email/zurb_2/notification/body.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Email/zurb_2/notification/body.html.twig b/Resources/views/Email/zurb_2/notification/body.html.twig index 0a52d36b..28a62de3 100644 --- a/Resources/views/Email/zurb_2/notification/body.html.twig +++ b/Resources/views/Email/zurb_2/notification/body.html.twig @@ -26,7 +26,7 @@ {% if markdown %} {{ include('@email/zurb_2/notification/content_markdown.html.twig') }} {% else %} - {{ (raw ? content|raw : content)|nl2br }} + {{ raw ? content|raw : content|nl2br }} {% endif %} {% endblock %} From 49db928085c5a1241e362feb029d6abf640a2c79 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 16 Feb 2023 10:33:00 +0100 Subject: [PATCH 06/13] CS fix --- Mime/WrappedTemplatedEmail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mime/WrappedTemplatedEmail.php b/Mime/WrappedTemplatedEmail.php index b214ae8a..853c0142 100644 --- a/Mime/WrappedTemplatedEmail.php +++ b/Mime/WrappedTemplatedEmail.php @@ -36,7 +36,7 @@ public function toName(): string } /** - * @param string $image A Twig path to the image file. It's recommended to define + * @param string $image A Twig path to the image file. It's recommended to define * some Twig namespace for email images (e.g. '@email/images/logo.png'). * @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png'). * Some email clients require this to display embedded images. @@ -54,9 +54,9 @@ public function image(string $image, string $contentType = null): string } /** - * @param string $file A Twig path to the file. It's recommended to define + * @param string $file A Twig path to the file. It's recommended to define * some Twig namespace for email files (e.g. '@email/files/contract.pdf'). - * @param string|null $name A custom file name that overrides the original name of the attached file. + * @param string|null $name A custom file name that overrides the original name of the attached file * @param string|null $contentType The media type (i.e. MIME type) of the file (e.g. 'application/pdf'). * Some email clients require this to display attached files. */ From 019f98c5e96d180f2e507967d0c4cdc195ecfd30 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 17 Feb 2023 14:46:47 +0100 Subject: [PATCH 07/13] do not drop embed label classes --- Resources/views/Form/bootstrap_3_layout.html.twig | 4 ++++ Resources/views/Form/bootstrap_4_layout.html.twig | 4 ++++ Resources/views/Form/foundation_5_layout.html.twig | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Resources/views/Form/bootstrap_3_layout.html.twig b/Resources/views/Form/bootstrap_3_layout.html.twig index 865f9078..f4e313b4 100644 --- a/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/Resources/views/Form/bootstrap_3_layout.html.twig @@ -90,6 +90,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ diff --git a/Resources/views/Form/bootstrap_4_layout.html.twig b/Resources/views/Form/bootstrap_4_layout.html.twig index 9aa6081e..a7ce3e23 100644 --- a/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/Resources/views/Form/bootstrap_4_layout.html.twig @@ -283,6 +283,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ diff --git a/Resources/views/Form/foundation_5_layout.html.twig b/Resources/views/Form/foundation_5_layout.html.twig index f8c51b83..345695f6 100644 --- a/Resources/views/Form/foundation_5_layout.html.twig +++ b/Resources/views/Form/foundation_5_layout.html.twig @@ -253,6 +253,10 @@ {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {% if label is empty %} {%- if label_format is not empty -%} {% set label = label_format|replace({ From d2d50dc32b8aea745bba3f3cdac3582d7a4fa988 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 22 Feb 2023 17:58:05 +0100 Subject: [PATCH 08/13] do not drop embed label classes --- Resources/views/Form/bootstrap_4_layout.html.twig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Resources/views/Form/bootstrap_4_layout.html.twig b/Resources/views/Form/bootstrap_4_layout.html.twig index 3e9904ad..458cc684 100644 --- a/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/Resources/views/Form/bootstrap_4_layout.html.twig @@ -261,6 +261,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {{ widget|raw }} From 4b4b345193bcf1d5392e2b3479396b77c2dc9cec Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 30 Dec 2022 15:09:11 +0100 Subject: [PATCH 09/13] [Translation] Handle the translation of empty strings --- Extension/TranslationExtension.php | 4 ++++ Tests/Extension/TranslationExtensionTest.php | 1 + 2 files changed, 5 insertions(+) diff --git a/Extension/TranslationExtension.php b/Extension/TranslationExtension.php index c2797d83..d5034809 100644 --- a/Extension/TranslationExtension.php +++ b/Extension/TranslationExtension.php @@ -116,6 +116,10 @@ public function trans($message, $arguments = [], string $domain = null, string $ throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments))); } + if ($message instanceof TranslatableMessage && '' === $message->getMessage()) { + return ''; + } + return $message->trans($this->getTranslator(), $locale ?? (\is_string($arguments) ? $arguments : null)); } diff --git a/Tests/Extension/TranslationExtensionTest.php b/Tests/Extension/TranslationExtensionTest.php index 86f50da0..a05f15f6 100644 --- a/Tests/Extension/TranslationExtensionTest.php +++ b/Tests/Extension/TranslationExtensionTest.php @@ -124,6 +124,7 @@ public function getTransTests() ['{{ foo|trans }}', '', ['foo' => null]], // trans object + ['{{ t("")|trans }}', ''], ['{{ t("Hello")|trans }}', 'Hello'], ['{{ t(name)|trans }}', 'Symfony', ['name' => 'Symfony']], ['{{ t(hello, { \'%name%\': \'Symfony\' })|trans }}', 'Hello Symfony', ['hello' => 'Hello %name%']], From bd1cad2b2fea04e24966c8b1f2b00710ebf26008 Mon Sep 17 00:00:00 2001 From: Wim Hendrikx Date: Sat, 21 Jan 2023 16:13:34 +0100 Subject: [PATCH 10/13] [TwigBridge] Allow floats in html5 input type number field --- .../AbstractBootstrap3LayoutTestCase.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/Extension/AbstractBootstrap3LayoutTestCase.php b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php index aa52233a..16cb900b 100644 --- a/Tests/Extension/AbstractBootstrap3LayoutTestCase.php +++ b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php @@ -2154,6 +2154,25 @@ public function testRenderNumberWithHtml5NumberType() $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="number"] + [@step="any"] + [@name="name"] + [@class="my&class form-control"] + [@value="1234.56"] +' + ); + } + + public function testRenderNumberWithHtml5NumberTypeAndStepAttribute() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [ + 'html5' => true, + 'attr' => ['step' => '0.1'], + ]); + + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], + '/input + [@type="number"] + [@step="0.1"] [@name="name"] [@class="my&class form-control"] [@value="1234.56"] From beb4caf3a20a0acc5e2b8760dbdee2034ac0f4a6 Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sun, 5 Mar 2023 11:59:41 +0100 Subject: [PATCH 11/13] [TwigBridge] Fix flagged malicious url --- Resources/views/Email/zurb_2/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Email/zurb_2/main.css b/Resources/views/Email/zurb_2/main.css index b826813e..dab0df58 100644 --- a/Resources/views/Email/zurb_2/main.css +++ b/Resources/views/Email/zurb_2/main.css @@ -1,7 +1,7 @@ /* * Copyright (c) 2017 ZURB, inc. -- MIT License * - * https://raw.githubusercontent.com/foundation/foundation-emails/v2.2.1/dist/foundation-emails.css + * https://github.com/foundation/foundation-emails/blob/v2.2.1/dist/foundation-emails.css */ .wrapper { From 0462d7ffaa088c5ef4950d63633c49fae383c75a Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 6 Mar 2023 20:42:33 +0100 Subject: [PATCH 12/13] [Tests] Remove occurrences of `withConsecutive()` --- Tests/Extension/StopwatchExtensionTest.php | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Tests/Extension/StopwatchExtensionTest.php b/Tests/Extension/StopwatchExtensionTest.php index 59a39374..d7ff03d7 100644 --- a/Tests/Extension/StopwatchExtensionTest.php +++ b/Tests/Extension/StopwatchExtensionTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\StopwatchExtension; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\Stopwatch\StopwatchEvent; use Twig\Environment; use Twig\Error\RuntimeError; use Twig\Loader\ArrayLoader; @@ -67,12 +68,29 @@ protected function getStopwatch($events = []) $expectedStopCalls[] = [$this->equalTo($eventName)]; } - $startInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls)) - ->method('start'); - \call_user_func_array([$startInvocationMocker, 'withConsecutive'], $expectedStartCalls); - $stopInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls)) - ->method('stop'); - \call_user_func_array([$stopInvocationMocker, 'withConsecutive'], $expectedStopCalls); + $stopwatch + ->expects($this->exactly($expectedCalls)) + ->method('start') + ->willReturnCallback(function (string $name, string $category) use (&$expectedStartCalls) { + [$expectedName, $expectedCategory] = array_shift($expectedStartCalls); + + $expectedName->evaluate($name); + $this->assertSame($expectedCategory, $category); + + return $this->createMock(StopwatchEvent::class); + }) + ; + + $stopwatch + ->expects($this->exactly($expectedCalls)) + ->method('stop') + ->willReturnCallback(function (string $name) use (&$expectedStopCalls) { + [$expectedName] = array_shift($expectedStopCalls); + $expectedName->evaluate($name); + + return $this->createMock(StopwatchEvent::class); + }) + ; return $stopwatch; } From 3414196db79c0f1a1315cdfd76cfbd55f9e68bc1 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 10 Mar 2023 17:29:15 +0100 Subject: [PATCH 13/13] [Tests] Remove `withConsecutive()` calls from tests --- .../TemplateAttributeListenerTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Tests/EventListener/TemplateAttributeListenerTest.php b/Tests/EventListener/TemplateAttributeListenerTest.php index 8f6d6a2c..e1fb7f95 100644 --- a/Tests/EventListener/TemplateAttributeListenerTest.php +++ b/Tests/EventListener/TemplateAttributeListenerTest.php @@ -29,12 +29,18 @@ public function testAttribute() $twig = $this->createMock(Environment::class); $twig->expects($this->exactly(3)) ->method('render') - ->withConsecutive( - ['templates/foo.html.twig', ['foo' => 'bar']], - ['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']], - ['templates/foo.html.twig', []], - ) - ->willReturn('Bar'); + ->willReturnCallback(function (...$args) { + static $series = [ + ['templates/foo.html.twig', ['foo' => 'bar']], + ['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']], + ['templates/foo.html.twig', []], + ]; + + $this->assertSame(array_shift($series), $args); + + return 'Bar'; + }) + ; $request = new Request(); $kernel = $this->createMock(HttpKernelInterface::class);