Skip to content

Commit 05e61ff

Browse files
committed
feature #57839 [Form] Deprecate VersionAwareTest trait (derrabus)
This PR was merged into the 7.2 branch. Discussion ---------- [Form] Deprecate VersionAwareTest trait | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Issues | N/A | License | MIT With this trait, downstream projects can check if they have at least Symfony Form 4.4 installed. That check should really be a no-op these days. I haven't removed the usages of this trait since downstream code might still rely on its presence. But I could eliminate all calls to the method that the trait provides. Commits ------- bc3ee44 [Form] Deprecate VersionAwareTest trait
2 parents ab9d2f2 + bc3ee44 commit 05e61ff

File tree

7 files changed

+18
-63
lines changed

7 files changed

+18
-63
lines changed

UPGRADE-7.2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Read more about this in the [Symfony documentation](https://symfony.com/doc/7.2/
88

99
If you're upgrading from a version below 7.1, follow the [7.1 upgrade guide](UPGRADE-7.1.md) first.
1010

11+
Form
12+
----
13+
14+
* Deprecate the `VersionAwareTest` trait, use feature detection instead
15+
1116
FrameworkBundle
1217
---------------
1318

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTestCase.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,8 +2869,6 @@ public function testColor()
28692869

28702870
public function testWeekSingleText()
28712871
{
2872-
$this->requiresFeatureSet(404);
2873-
28742872
$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
28752873
'input' => 'string',
28762874
'widget' => 'single_text',
@@ -2889,8 +2887,6 @@ public function testWeekSingleText()
28892887

28902888
public function testWeekSingleTextNoHtml5()
28912889
{
2892-
$this->requiresFeatureSet(404);
2893-
28942890
$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
28952891
'input' => 'string',
28962892
'widget' => 'single_text',
@@ -2910,8 +2906,6 @@ public function testWeekSingleTextNoHtml5()
29102906

29112907
public function testWeekChoices()
29122908
{
2913-
$this->requiresFeatureSet(404);
2914-
29152909
$data = ['year' => (int) date('Y'), 'week' => 1];
29162910

29172911
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', $data, [
@@ -2938,8 +2932,6 @@ public function testWeekChoices()
29382932

29392933
public function testWeekText()
29402934
{
2941-
$this->requiresFeatureSet(404);
2942-
29432935
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '2000-W01', [
29442936
'input' => 'string',
29452937
'widget' => 'text',

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,8 +1842,6 @@ public function testTimezoneWithPlaceholder()
18421842

18431843
public function testWeekChoices()
18441844
{
1845-
$this->requiresFeatureSet(404);
1846-
18471845
$data = ['year' => (int) date('Y'), 'week' => 1];
18481846

18491847
$form = $this->factory->createNamed('name', WeekType::class, $data, [

src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@
1919
use Symfony\Component\Form\FormError;
2020
use Symfony\Component\Form\FormExtensionInterface;
2121
use Symfony\Component\Form\FormView;
22-
use Symfony\Component\Form\Tests\VersionAwareTest;
2322
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
2423
use Symfony\Component\Translation\TranslatableMessage;
2524
use Symfony\Contracts\Translation\TranslatableInterface;
2625
use Symfony\Contracts\Translation\TranslatorInterface;
2726

2827
abstract class AbstractLayoutTestCase extends FormLayoutTestCase
2928
{
30-
use VersionAwareTest;
31-
3229
protected MockObject&CsrfTokenManagerInterface $csrfTokenManager;
3330
protected array $testableFeatures = [];
3431

@@ -676,8 +673,6 @@ public function testSingleExpandedChoiceAttributesWithMainAttributes()
676673

677674
public function testSingleChoiceWithPreferred()
678675
{
679-
$this->requiresFeatureSet(404);
680-
681676
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
682677
'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'],
683678
'preferred_choices' => ['&b'],
@@ -702,8 +697,6 @@ public function testSingleChoiceWithPreferred()
702697

703698
public function testSingleChoiceWithPreferredAndNoSeparator()
704699
{
705-
$this->requiresFeatureSet(404);
706-
707700
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
708701
'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'],
709702
'preferred_choices' => ['&b'],
@@ -727,8 +720,6 @@ public function testSingleChoiceWithPreferredAndNoSeparator()
727720

728721
public function testSingleChoiceWithPreferredAndBlankSeparator()
729722
{
730-
$this->requiresFeatureSet(404);
731-
732723
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
733724
'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'],
734725
'preferred_choices' => ['&b'],
@@ -753,8 +744,6 @@ public function testSingleChoiceWithPreferredAndBlankSeparator()
753744

754745
public function testChoiceWithOnlyPreferred()
755746
{
756-
$this->requiresFeatureSet(404);
757-
758747
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
759748
'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'],
760749
'preferred_choices' => ['&a', '&b'],
@@ -1818,8 +1807,6 @@ public function testNumber()
18181807

18191808
public function testRenderNumberWithHtml5NumberType()
18201809
{
1821-
$this->requiresFeatureSet(403);
1822-
18231810
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
18241811
'html5' => true,
18251812
]);
@@ -1836,8 +1823,6 @@ public function testRenderNumberWithHtml5NumberType()
18361823

18371824
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
18381825
{
1839-
$this->requiresFeatureSet(403);
1840-
18411826
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
18421827
'html5' => true,
18431828
'attr' => ['step' => '0.1'],
@@ -1912,8 +1897,6 @@ public function testPercent()
19121897

19131898
public function testPercentNoSymbol()
19141899
{
1915-
$this->requiresFeatureSet(403);
1916-
19171900
$form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => false, 'rounding_mode' => \NumberFormatter::ROUND_CEILING]);
19181901
$this->assertWidgetMatchesXpath($form->createView(), [],
19191902
'/input
@@ -1927,8 +1910,6 @@ public function testPercentNoSymbol()
19271910

19281911
public function testPercentCustomSymbol()
19291912
{
1930-
$this->requiresFeatureSet(403);
1931-
19321913
$form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => '', 'rounding_mode' => \NumberFormatter::ROUND_CEILING]);
19331914
$this->assertWidgetMatchesXpath($form->createView(), [],
19341915
'/input
@@ -2606,8 +2587,6 @@ public function testColor()
26062587

26072588
public function testLabelWithTranslationParameters()
26082589
{
2609-
$this->requiresFeatureSet(403);
2610-
26112590
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
26122591
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
26132592
'label_translation_parameters' => [
@@ -2625,8 +2604,6 @@ public function testLabelWithTranslationParameters()
26252604

26262605
public function testHelpWithTranslationParameters()
26272606
{
2628-
$this->requiresFeatureSet(403);
2629-
26302607
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
26312608
'help' => 'for company %company%',
26322609
'help_translation_parameters' => [
@@ -2697,8 +2674,6 @@ public function trans(TranslatorInterface $translator, ?string $locale = null):
26972674

26982675
public function testAttributesWithTranslationParameters()
26992676
{
2700-
$this->requiresFeatureSet(403);
2701-
27022677
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
27032678
'attr' => [
27042679
'title' => 'Message to %company%',
@@ -2720,8 +2695,6 @@ public function testAttributesWithTranslationParameters()
27202695

27212696
public function testButtonWithTranslationParameters()
27222697
{
2723-
$this->requiresFeatureSet(403);
2724-
27252698
$form = $this->factory->createNamedBuilder('myform')
27262699
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
27272700
'label' => 'Submit to %company%',
@@ -2745,8 +2718,6 @@ public function testButtonWithTranslationParameters()
27452718
*/
27462719
public function testSubmitFormNoValidate(bool $validate)
27472720
{
2748-
$this->requiresFeatureSet(404);
2749-
27502721
$form = $this->factory->create(SubmitType::class, null, [
27512722
'validate' => $validate,
27522723
]);
@@ -2776,8 +2747,6 @@ public static function submitFormNoValidateProvider()
27762747

27772748
public function testWeekSingleText()
27782749
{
2779-
$this->requiresFeatureSet(404);
2780-
27812750
$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
27822751
'input' => 'string',
27832752
'widget' => 'single_text',
@@ -2795,8 +2764,6 @@ public function testWeekSingleText()
27952764

27962765
public function testWeekSingleTextNoHtml5()
27972766
{
2798-
$this->requiresFeatureSet(404);
2799-
28002767
$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
28012768
'input' => 'string',
28022769
'widget' => 'single_text',
@@ -2815,8 +2782,6 @@ public function testWeekSingleTextNoHtml5()
28152782

28162783
public function testWeekChoices()
28172784
{
2818-
$this->requiresFeatureSet(404);
2819-
28202785
$data = ['year' => (int) date('Y'), 'week' => 1];
28212786

28222787
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', $data, [
@@ -2841,8 +2806,6 @@ public function testWeekChoices()
28412806

28422807
public function testWeekText()
28432808
{
2844-
$this->requiresFeatureSet(404);
2845-
28462809
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '2000-W01', [
28472810
'input' => 'string',
28482811
'widget' => 'text',

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Deprecate the `VersionAwareTest` trait, use feature detection instead
8+
49
7.1
510
---
611

src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTestCase.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ public function testDefaultTranslationDomain()
114114

115115
public function testPassLabelTranslationParametersToView()
116116
{
117-
$this->requiresFeatureSet(403);
118-
119117
$view = $this->factory->create($this->getTestedType(), null, array_merge($this->getTestOptions(), [
120118
'label_translation_parameters' => ['%param%' => 'value'],
121119
]))
@@ -126,8 +124,6 @@ public function testPassLabelTranslationParametersToView()
126124

127125
public function testPassAttrTranslationParametersToView()
128126
{
129-
$this->requiresFeatureSet(403);
130-
131127
$view = $this->factory->create($this->getTestedType(), null, array_merge($this->getTestOptions(), [
132128
'attr_translation_parameters' => ['%param%' => 'value'],
133129
]))
@@ -138,8 +134,6 @@ public function testPassAttrTranslationParametersToView()
138134

139135
public function testInheritLabelTranslationParametersFromParent()
140136
{
141-
$this->requiresFeatureSet(403);
142-
143137
$view = $this->factory
144138
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
145139
'label_translation_parameters' => ['%param%' => 'value'],
@@ -153,8 +147,6 @@ public function testInheritLabelTranslationParametersFromParent()
153147

154148
public function testInheritAttrTranslationParametersFromParent()
155149
{
156-
$this->requiresFeatureSet(403);
157-
158150
$view = $this->factory
159151
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
160152
'attr_translation_parameters' => ['%param%' => 'value'],
@@ -168,8 +160,6 @@ public function testInheritAttrTranslationParametersFromParent()
168160

169161
public function testPreferOwnLabelTranslationParameters()
170162
{
171-
$this->requiresFeatureSet(403);
172-
173163
$view = $this->factory
174164
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
175165
'label_translation_parameters' => ['%parent_param%' => 'parent_value', '%override_param%' => 'parent_override_value'],
@@ -185,8 +175,6 @@ public function testPreferOwnLabelTranslationParameters()
185175

186176
public function testPreferOwnAttrTranslationParameters()
187177
{
188-
$this->requiresFeatureSet(403);
189-
190178
$view = $this->factory
191179
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
192180
'attr_translation_parameters' => ['%parent_param%' => 'parent_value', '%override_param%' => 'parent_override_value'],
@@ -202,8 +190,6 @@ public function testPreferOwnAttrTranslationParameters()
202190

203191
public function testDefaultLabelTranslationParameters()
204192
{
205-
$this->requiresFeatureSet(403);
206-
207193
$view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE)
208194
->add('child', $this->getTestedType(), $this->getTestOptions())
209195
->getForm()
@@ -214,8 +200,6 @@ public function testDefaultLabelTranslationParameters()
214200

215201
public function testDefaultAttrTranslationParameters()
216202
{
217-
$this->requiresFeatureSet(403);
218-
219203
$view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE)
220204
->add('child', $this->getTestedType(), $this->getTestOptions())
221205
->getForm()

src/Symfony/Component/Form/Tests/VersionAwareTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
/**
15+
* @deprecated since Symfony 7.2, use feature detection instead.
16+
*/
1417
trait VersionAwareTest
1518
{
1619
protected static int $supportedFeatureSetVersion = 404;
1720

21+
/**
22+
* @deprecated since Symfony 7.2, use feature detection instead.
23+
*/
1824
protected function requiresFeatureSet(int $requiredFeatureSetVersion)
1925
{
26+
trigger_deprecation('symfony/form', '7.2', 'The "%s" trait is deprecated, use feature detection instead.', VersionAwareTest::class);
27+
2028
if ($requiredFeatureSetVersion > static::$supportedFeatureSetVersion) {
2129
$this->markTestSkipped(\sprintf('Test requires features from symfony/form %.2f but only version %.2f is supported.', $requiredFeatureSetVersion / 100, static::$supportedFeatureSetVersion / 100));
2230
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy