1111
1212namespace Symfony \Component \Process \Tests ;
1313
14+ use PHPUnit \Framework \Attributes \DataProvider ;
15+ use PHPUnit \Framework \Attributes \Group ;
16+ use PHPUnit \Framework \Attributes \RequiresPhpExtension ;
1417use PHPUnit \Framework \TestCase ;
1518use Symfony \Component \Process \Exception \InvalidArgumentException ;
1619use Symfony \Component \Process \Exception \LogicException ;
@@ -66,9 +69,7 @@ public function testInvalidCwd()
6669 $ cmd ->run ();
6770 }
6871
69- /**
70- * @dataProvider invalidProcessProvider
71- */
72+ #[DataProvider('invalidProcessProvider ' )]
7273 public function testInvalidCommand (Process $ process )
7374 {
7475 // An invalid command should not fail during start
@@ -83,9 +84,7 @@ public static function invalidProcessProvider(): array
8384 ];
8485 }
8586
86- /**
87- * @group transient-on-windows
88- */
87+ #[Group('transient-on-windows ' )]
8988 public function testThatProcessDoesNotThrowWarningDuringRun ()
9089 {
9190 @trigger_error ('Test Error ' , \E_USER_NOTICE );
@@ -123,9 +122,7 @@ public function testFloatAndNullTimeout()
123122 $ this ->assertNull ($ p ->getTimeout ());
124123 }
125124
126- /**
127- * @requires extension pcntl
128- */
125+ #[RequiresPhpExtension('pcntl ' )]
129126 public function testStopWithTimeoutIsActuallyWorking ()
130127 {
131128 $ p = $ this ->getProcess ([self ::$ phpBin , __DIR__ .'/NonStopableProcess.php ' , 30 ]);
@@ -147,9 +144,7 @@ public function testStopWithTimeoutIsActuallyWorking()
147144 $ this ->assertLessThan (15 , microtime (true ) - $ start );
148145 }
149146
150- /**
151- * @group transient-on-windows
152- */
147+ #[Group('transient-on-windows ' )]
153148 public function testWaitUntilSpecificOutput ()
154149 {
155150 $ p = $ this ->getProcess ([self ::$ phpBin , __DIR__ .'/KillableProcessWithOutput.php ' ]);
@@ -233,9 +228,8 @@ public function testReadSupportIsDisabledWithoutCallback()
233228
234229 /**
235230 * tests results from sub processes.
236- *
237- * @dataProvider responsesCodeProvider
238231 */
232+ #[DataProvider('responsesCodeProvider ' )]
239233 public function testProcessResponses ($ expected , $ getter , $ code )
240234 {
241235 $ p = $ this ->getProcessForCode ($ code );
@@ -246,9 +240,8 @@ public function testProcessResponses($expected, $getter, $code)
246240
247241 /**
248242 * tests results from sub processes.
249- *
250- * @dataProvider pipesCodeProvider
251243 */
244+ #[DataProvider('pipesCodeProvider ' )]
252245 public function testProcessPipes ($ code , $ size )
253246 {
254247 $ expected = str_repeat (str_repeat ('* ' , 1024 ), $ size ).'! ' ;
@@ -262,9 +255,7 @@ public function testProcessPipes($code, $size)
262255 $ this ->assertEquals ($ expectedLength , \strlen ($ p ->getErrorOutput ()));
263256 }
264257
265- /**
266- * @dataProvider pipesCodeProvider
267- */
258+ #[DataProvider('pipesCodeProvider ' )]
268259 public function testSetStreamAsInput ($ code , $ size )
269260 {
270261 $ expected = str_repeat (str_repeat ('* ' , 1024 ), $ size ).'! ' ;
@@ -319,9 +310,7 @@ public function testSetInputWhileRunningThrowsAnException()
319310 throw $ e ;
320311 }
321312
322- /**
323- * @dataProvider provideInvalidInputValues
324- */
313+ #[DataProvider('provideInvalidInputValues ' )]
325314 public function testInvalidInput (array |object $ value )
326315 {
327316 $ process = $ this ->getProcess ('foo ' );
@@ -340,9 +329,7 @@ public static function provideInvalidInputValues()
340329 ];
341330 }
342331
343- /**
344- * @dataProvider provideInputValues
345- */
332+ #[DataProvider('provideInputValues ' )]
346333 public function testValidInput (?string $ expected , float |string |null $ value )
347334 {
348335 $ process = $ this ->getProcess ('foo ' );
@@ -373,9 +360,7 @@ public static function chainedCommandsOutputProvider()
373360 ];
374361 }
375362
376- /**
377- * @dataProvider chainedCommandsOutputProvider
378- */
363+ #[DataProvider('chainedCommandsOutputProvider ' )]
379364 public function testChainedCommandsOutput ($ expected , $ operator , $ input )
380365 {
381366 $ process = $ this ->getProcess (\sprintf ('echo %s %s echo %s ' , $ input , $ operator , $ input ));
@@ -425,9 +410,7 @@ public function testFlushErrorOutput()
425410 $ this ->assertSame ('' , $ p ->getErrorOutput ());
426411 }
427412
428- /**
429- * @dataProvider provideIncrementalOutput
430- */
413+ #[DataProvider('provideIncrementalOutput ' )]
431414 public function testIncrementalOutput ($ getOutput , $ getIncrementalOutput , $ uri )
432415 {
433416 $ lock = tempnam (sys_get_temp_dir (), __FUNCTION__ );
@@ -949,9 +932,7 @@ public function testGetPidIsNullAfterRun()
949932 $ this ->assertNull ($ process ->getPid ());
950933 }
951934
952- /**
953- * @requires extension pcntl
954- */
935+ #[RequiresPhpExtension('pcntl ' )]
955936 public function testSignal ()
956937 {
957938 $ process = $ this ->getProcess ([self ::$ phpBin , __DIR__ .'/SignalListener.php ' ]);
@@ -966,9 +947,7 @@ public function testSignal()
966947 $ this ->assertEquals ('Caught SIGUSR1 ' , $ process ->getOutput ());
967948 }
968949
969- /**
970- * @requires extension pcntl
971- */
950+ #[RequiresPhpExtension('pcntl ' )]
972951 public function testExitCodeIsAvailableAfterSignal ()
973952 {
974953 $ process = $ this ->getProcess ('sleep 4 ' );
@@ -995,9 +974,7 @@ public function testSignalProcessNotRunning()
995974 $ process ->signal (1 ); // SIGHUP
996975 }
997976
998- /**
999- * @dataProvider provideMethodsThatNeedARunningProcess
1000- */
977+ #[DataProvider('provideMethodsThatNeedARunningProcess ' )]
1001978 public function testMethodsThatNeedARunningProcess ($ method )
1002979 {
1003980 $ process = $ this ->getProcess ('foo ' );
@@ -1019,9 +996,7 @@ public static function provideMethodsThatNeedARunningProcess()
1019996 ];
1020997 }
1021998
1022- /**
1023- * @dataProvider provideMethodsThatNeedATerminatedProcess
1024- */
999+ #[DataProvider('provideMethodsThatNeedATerminatedProcess ' )]
10251000 public function testMethodsThatNeedATerminatedProcess ($ method )
10261001 {
10271002 $ this ->expectException (LogicException::class);
@@ -1139,9 +1114,7 @@ public function testSetNullIdleTimeoutWhileOutputIsDisabled()
11391114 $ this ->assertSame ($ process , $ process ->setIdleTimeout (null ));
11401115 }
11411116
1142- /**
1143- * @dataProvider provideOutputFetchingMethods
1144- */
1117+ #[DataProvider('provideOutputFetchingMethods ' )]
11451118 public function testGetOutputWhileDisabled ($ fetchMethod )
11461119 {
11471120 $ p = $ this ->getProcessForCode ('sleep(41); ' );
@@ -1225,9 +1198,7 @@ public static function pipesCodeProvider()
12251198 return $ codes ;
12261199 }
12271200
1228- /**
1229- * @dataProvider provideVariousIncrementals
1230- */
1201+ #[DataProvider('provideVariousIncrementals ' )]
12311202 public function testIncrementalOutputDoesNotRequireAnotherCall ($ stream , $ method )
12321203 {
12331204 $ process = $ this ->getProcessForCode ('$n = 0; while ($n < 3) { file_put_contents( \'' .$ stream .'\', $n, 1); $n++; usleep(1000); } ' , null , null , null , null );
@@ -1495,9 +1466,7 @@ public function testGetCommandLine()
14951466 $ this ->assertSame ($ expected , $ p ->getCommandLine ());
14961467 }
14971468
1498- /**
1499- * @dataProvider provideEscapeArgument
1500- */
1469+ #[DataProvider('provideEscapeArgument ' )]
15011470 public function testEscapeArgument ($ arg )
15021471 {
15031472 $ p = new Process ([self ::$ phpBin , '-r ' , 'echo $argv[1]; ' , $ arg ]);
@@ -1636,9 +1605,7 @@ public function testFailingProcessWithMultipleCallsToProcGetStatus()
16361605 $ this ->assertSame (123 , $ process ->getExitCode ());
16371606 }
16381607
1639- /**
1640- * @group slow
1641- */
1608+ #[Group('slow ' )]
16421609 public function testLongRunningProcessWithMultipleCallsToProcGetStatus ()
16431610 {
16441611 $ process = $ this ->getProcess ('sleep 1 && echo "done" && php -r "exit(0);" ' );
@@ -1651,9 +1618,7 @@ public function testLongRunningProcessWithMultipleCallsToProcGetStatus()
16511618 $ this ->assertSame (0 , $ process ->getExitCode ());
16521619 }
16531620
1654- /**
1655- * @group slow
1656- */
1621+ #[Group('slow ' )]
16571622 public function testLongRunningProcessWithMultipleCallsToProcGetStatusError ()
16581623 {
16591624 $ process = $ this ->getProcess ('sleep 1 && echo "failure" && php -r "exit(123);" ' );
@@ -1666,9 +1631,7 @@ public function testLongRunningProcessWithMultipleCallsToProcGetStatusError()
16661631 $ this ->assertSame (123 , $ process ->getExitCode ());
16671632 }
16681633
1669- /**
1670- * @group transient-on-windows
1671- */
1634+ #[Group('transient-on-windows ' )]
16721635 public function testNotTerminableInputPipe ()
16731636 {
16741637 $ process = $ this ->getProcess ('echo foo ' );
0 commit comments