1111
1212namespace Symfony \Component \Form \Tests ;
1313
14+ use PHPUnit \Framework \Attributes \DataProvider ;
1415use PHPUnit \Framework \TestCase ;
1516use Symfony \Component \EventDispatcher \EventDispatcher ;
1617use 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 )));
0 commit comments