Skip to content

Commit 89c8619

Browse files
minor #61299 replace PHPUnit annotations with attributes (xabbuh)
This PR was merged into the 7.4 branch. Discussion ---------- replace PHPUnit annotations with attributes | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- 982f89c61b9 replace PHPUnit annotations with attributes
2 parents 2f4edb8 + 48ad426 commit 89c8619

File tree

59 files changed

+235
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+235
-504
lines changed

Tests/AbstractRequestHandlerTestCase.php

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\EventDispatcher\EventDispatcher;
1617
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
@@ -76,9 +77,7 @@ public static function methodProvider(): array
7677
], self::methodExceptGetProvider());
7778
}
7879

79-
/**
80-
* @dataProvider methodProvider
81-
*/
80+
#[DataProvider('methodProvider')]
8281
public function testSubmitIfNameInRequest($method)
8382
{
8483
$form = $this->createForm('param1', $method);
@@ -93,9 +92,7 @@ public function testSubmitIfNameInRequest($method)
9392
$this->assertSame('DATA', $form->getData());
9493
}
9594

96-
/**
97-
* @dataProvider methodProvider
98-
*/
95+
#[DataProvider('methodProvider')]
9996
public function testDoNotSubmitIfWrongRequestMethod($method)
10097
{
10198
$form = $this->createForm('param1', $method);
@@ -111,9 +108,7 @@ public function testDoNotSubmitIfWrongRequestMethod($method)
111108
$this->assertFalse($form->isSubmitted());
112109
}
113110

114-
/**
115-
* @dataProvider methodExceptGetProvider
116-
*/
111+
#[DataProvider('methodExceptGetProvider')]
117112
public function testDoNoSubmitSimpleFormIfNameNotInRequestAndNotGetRequest($method)
118113
{
119114
$form = $this->createForm('param1', $method, false);
@@ -127,9 +122,7 @@ public function testDoNoSubmitSimpleFormIfNameNotInRequestAndNotGetRequest($meth
127122
$this->assertFalse($form->isSubmitted());
128123
}
129124

130-
/**
131-
* @dataProvider methodExceptGetProvider
132-
*/
125+
#[DataProvider('methodExceptGetProvider')]
133126
public function testDoNotSubmitCompoundFormIfNameNotInRequestAndNotGetRequest($method)
134127
{
135128
$form = $this->createForm('param1', $method, true);
@@ -156,9 +149,7 @@ public function testDoNotSubmitIfNameNotInRequestAndGetRequest()
156149
$this->assertFalse($form->isSubmitted());
157150
}
158151

159-
/**
160-
* @dataProvider methodProvider
161-
*/
152+
#[DataProvider('methodProvider')]
162153
public function testSubmitFormWithEmptyNameIfAtLeastOneFieldInRequest($method)
163154
{
164155
$form = $this->createForm('', $method, true);
@@ -185,9 +176,7 @@ public function testSubmitFormWithEmptyNameIfAtLeastOneFieldInRequest($method)
185176
$this->assertNull($form->get('param2')->getData());
186177
}
187178

188-
/**
189-
* @dataProvider methodProvider
190-
*/
179+
#[DataProvider('methodProvider')]
191180
public function testDoNotSubmitFormWithEmptyNameIfNoFieldInRequest($method)
192181
{
193182
$form = $this->createForm('', $method, true);
@@ -203,9 +192,7 @@ public function testDoNotSubmitFormWithEmptyNameIfNoFieldInRequest($method)
203192
$this->assertFalse($form->isSubmitted());
204193
}
205194

206-
/**
207-
* @dataProvider methodExceptGetProvider
208-
*/
195+
#[DataProvider('methodExceptGetProvider')]
209196
public function testMergeParamsAndFiles($method)
210197
{
211198
$form = $this->createForm('param1', $method, true);
@@ -248,9 +235,7 @@ public function testIntegerChildren()
248235
$this->assertSame('bar', $form->get('1')->getData());
249236
}
250237

251-
/**
252-
* @dataProvider methodExceptGetProvider
253-
*/
238+
#[DataProvider('methodExceptGetProvider')]
254239
public function testMergeParamsAndFilesMultiple($method)
255240
{
256241
$form = $this->createForm('param1', $method, true);
@@ -284,9 +269,7 @@ public function testMergeParamsAndFilesMultiple($method)
284269
$this->assertSame(['foo', 'bar', 'baz', $file1, $file2], $data);
285270
}
286271

287-
/**
288-
* @dataProvider methodExceptGetProvider
289-
*/
272+
#[DataProvider('methodExceptGetProvider')]
290273
public function testParamTakesPrecedenceOverFile($method)
291274
{
292275
$form = $this->createForm('param1', $method);
@@ -346,9 +329,7 @@ public function testMergeZeroIndexedCollection()
346329
$this->assertNotNull($itemsForm->get('0')->get('file'));
347330
}
348331

349-
/**
350-
* @dataProvider methodExceptGetProvider
351-
*/
332+
#[DataProvider('methodExceptGetProvider')]
352333
public function testSubmitFileIfNoParam($method)
353334
{
354335
$form = $this->createBuilder('param1', false, ['allow_file_upload' => true])
@@ -368,9 +349,7 @@ public function testSubmitFileIfNoParam($method)
368349
$this->assertSame($file, $form->getData());
369350
}
370351

371-
/**
372-
* @dataProvider methodExceptGetProvider
373-
*/
352+
#[DataProvider('methodExceptGetProvider')]
374353
public function testSubmitMultipleFiles($method)
375354
{
376355
$form = $this->createBuilder('param1', false, ['allow_file_upload' => true])
@@ -392,9 +371,7 @@ public function testSubmitMultipleFiles($method)
392371
$this->assertSame($file, $form->getData());
393372
}
394373

395-
/**
396-
* @dataProvider methodExceptGetProvider
397-
*/
374+
#[DataProvider('methodExceptGetProvider')]
398375
public function testSubmitFileWithNamelessForm($method)
399376
{
400377
$form = $this->createForm('', $method, true);
@@ -412,9 +389,7 @@ public function testSubmitFileWithNamelessForm($method)
412389
$this->assertSame($file, $fileForm->getData());
413390
}
414391

415-
/**
416-
* @dataProvider getPostMaxSizeFixtures
417-
*/
392+
#[DataProvider('getPostMaxSizeFixtures')]
418393
public function testAddFormErrorIfPostMaxSizeExceeded(?int $contentLength, string $iniMax, bool $shouldFail, array $errorParams = [])
419394
{
420395
$this->serverParams->contentLength = $contentLength;
@@ -463,9 +438,7 @@ public function testInvalidFilesAreRejected()
463438
$this->assertFalse($this->requestHandler->isFileUpload($this->getInvalidFile()));
464439
}
465440

466-
/**
467-
* @dataProvider uploadFileErrorCodes
468-
*/
441+
#[DataProvider('uploadFileErrorCodes')]
469442
public function testFailedFileUploadIsTurnedIntoFormError($errorCode, $expectedErrorCode)
470443
{
471444
$this->assertSame($expectedErrorCode, $this->requestHandler->getUploadFileError($this->getFailedUploadedFile($errorCode)));

Tests/ButtonBuilderTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Form\ButtonBuilder;
1617
use Symfony\Component\Form\Exception\InvalidArgumentException;
@@ -31,9 +32,7 @@ public static function getValidNames()
3132
];
3233
}
3334

34-
/**
35-
* @dataProvider getValidNames
36-
*/
35+
#[DataProvider('getValidNames')]
3736
public function testValidNames($name)
3837
{
3938
$this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder($name));
@@ -56,9 +55,7 @@ public static function getInvalidNames()
5655
];
5756
}
5857

59-
/**
60-
* @dataProvider getInvalidNames
61-
*/
58+
#[DataProvider('getInvalidNames')]
6259
public function testInvalidNames($name)
6360
{
6461
$this->expectException(InvalidArgumentException::class);

Tests/ButtonTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\EventDispatcher\EventDispatcher;
1617
use Symfony\Component\Form\ButtonBuilder;
@@ -37,9 +38,7 @@ public function testSetParentOnSubmittedButton()
3738
$button->setParent($this->getFormBuilder()->getForm());
3839
}
3940

40-
/**
41-
* @dataProvider getDisabledStates
42-
*/
41+
#[DataProvider('getDisabledStates')]
4342
public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result)
4443
{
4544
$form = $this->getFormBuilder()

Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\ChoiceList\Factory;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1617
use Symfony\Component\Form\ChoiceList\ChoiceList;
@@ -71,9 +72,7 @@ public function testCreateFromChoicesGroupedChoices()
7172
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2);
7273
}
7374

74-
/**
75-
* @dataProvider provideSameChoices
76-
*/
75+
#[DataProvider('provideSameChoices')]
7776
public function testCreateFromChoicesSameChoices($choice1, $choice2)
7877
{
7978
$list1 = $this->factory->createListFromChoices([$choice1]);
@@ -84,9 +83,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
8483
$this->assertEquals(new ArrayChoiceList([$choice2]), $list2);
8584
}
8685

87-
/**
88-
* @dataProvider provideDistinguishedChoices
89-
*/
86+
#[DataProvider('provideDistinguishedChoices')]
9087
public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
9188
{
9289
$list1 = $this->factory->createListFromChoices([$choice1]);

Tests/Command/DebugCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Console\Application;
1617
use Symfony\Component\Console\Exception\InvalidArgumentException;
@@ -186,9 +187,7 @@ class:%s
186187
, $tester->getDisplay(true));
187188
}
188189

189-
/**
190-
* @dataProvider provideCompletionSuggestions
191-
*/
190+
#[DataProvider('provideCompletionSuggestions')]
192191
public function testComplete(array $input, array $expectedSuggestions)
193192
{
194193
$formRegistry = new FormRegistry([], new ResolvedFormTypeFactory());

Tests/CompoundFormPerformanceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use Symfony\Component\Form\Test\FormPerformanceTestCase;
1516

1617
/**
@@ -20,9 +21,8 @@ class CompoundFormPerformanceTest extends FormPerformanceTestCase
2021
{
2122
/**
2223
* Create a compound form multiple times, as happens in a collection form.
23-
*
24-
* @group benchmark
2524
*/
25+
#[Group('benchmark')]
2626
public function testArrayBasedForm()
2727
{
2828
$this->setMaxRunningTime(1);

Tests/CompoundFormTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\EventDispatcher\EventDispatcher;
1617
use Symfony\Component\Form\Exception\AlreadySubmittedException;
@@ -585,9 +586,7 @@ public static function requestMethodProvider(): array
585586
];
586587
}
587588

588-
/**
589-
* @dataProvider requestMethodProvider
590-
*/
589+
#[DataProvider('requestMethodProvider')]
591590
public function testSubmitPostOrPutRequest($method)
592591
{
593592
$path = tempnam(sys_get_temp_dir(), 'sf');
@@ -633,9 +632,7 @@ public function testSubmitPostOrPutRequest($method)
633632
unlink($path);
634633
}
635634

636-
/**
637-
* @dataProvider requestMethodProvider
638-
*/
635+
#[DataProvider('requestMethodProvider')]
639636
public function testSubmitPostOrPutRequestWithEmptyRootFormName($method)
640637
{
641638
$path = tempnam(sys_get_temp_dir(), 'sf');
@@ -681,9 +678,7 @@ public function testSubmitPostOrPutRequestWithEmptyRootFormName($method)
681678
unlink($path);
682679
}
683680

684-
/**
685-
* @dataProvider requestMethodProvider
686-
*/
681+
#[DataProvider('requestMethodProvider')]
687682
public function testSubmitPostOrPutRequestWithSingleChildForm($method)
688683
{
689684
$path = tempnam(sys_get_temp_dir(), 'sf');
@@ -718,9 +713,7 @@ public function testSubmitPostOrPutRequestWithSingleChildForm($method)
718713
unlink($path);
719714
}
720715

721-
/**
722-
* @dataProvider requestMethodProvider
723-
*/
716+
#[DataProvider('requestMethodProvider')]
724717
public function testSubmitPostOrPutRequestWithSingleChildFormUploadedFile($method)
725718
{
726719
$path = tempnam(sys_get_temp_dir(), 'sf');

Tests/Console/Descriptor/AbstractDescriptorTestCase.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Console\Descriptor;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Console\Input\ArrayInput;
1617
use Symfony\Component\Console\Output\BufferedOutput;
@@ -41,7 +42,7 @@ protected function tearDown(): void
4142
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
4243
}
4344

44-
/** @dataProvider getDescribeDefaultsTestData */
45+
#[DataProvider('getDescribeDefaultsTestData')]
4546
public function testDescribeDefaults($object, array $options, $fixtureName)
4647
{
4748
$describedObject = $this->getObjectDescription($object, $options);
@@ -54,7 +55,7 @@ public function testDescribeDefaults($object, array $options, $fixtureName)
5455
}
5556
}
5657

57-
/** @dataProvider getDescribeResolvedFormTypeTestData */
58+
#[DataProvider('getDescribeResolvedFormTypeTestData')]
5859
public function testDescribeResolvedFormType(ResolvedFormTypeInterface $type, array $options, $fixtureName)
5960
{
6061
$describedObject = $this->getObjectDescription($type, $options);
@@ -67,7 +68,7 @@ public function testDescribeResolvedFormType(ResolvedFormTypeInterface $type, ar
6768
}
6869
}
6970

70-
/** @dataProvider getDescribeOptionTestData */
71+
#[DataProvider('getDescribeOptionTestData')]
7172
public function testDescribeOption(OptionsResolver $optionsResolver, array $options, $fixtureName)
7273
{
7374
$describedObject = $this->getObjectDescription($optionsResolver, $options);

Tests/DependencyInjection/FormPassTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\DependencyInjection;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1617
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@@ -115,9 +116,7 @@ public function testAddTaggedTypesToCsrfTypeExtension()
115116
$this->assertSame([__CLASS__.'_Type1' => 'the_token_id'], $csrfDefinition->getArgument(7));
116117
}
117118

118-
/**
119-
* @dataProvider addTaggedTypeExtensionsDataProvider
120-
*/
119+
#[DataProvider('addTaggedTypeExtensionsDataProvider')]
121120
public function testAddTaggedTypeExtensions(array $extensions, array $expectedRegisteredExtensions, array $parameters = [])
122121
{
123122
$container = $this->createContainerBuilder();
@@ -280,9 +279,7 @@ public function testAddTaggedGuessers()
280279
);
281280
}
282281

283-
/**
284-
* @dataProvider privateTaggedServicesProvider
285-
*/
282+
#[DataProvider('privateTaggedServicesProvider')]
286283
public function testPrivateTaggedServices($id, $class, $tagName, callable $assertion, array $tagAttributes = [])
287284
{
288285
$formPass = new FormPass();

0 commit comments

Comments
 (0)