@@ -328,11 +328,13 @@ public function testSetInputWhileRunningThrowsAnException()
328328 /**
329329 * @dataProvider provideInvalidInputValues
330330 */
331- public function testInvalidInput ($ value )
331+ public function testInvalidInput (array | object $ value )
332332 {
333+ $ process = $ this ->getProcess ('foo ' );
334+
333335 $ this ->expectException (InvalidArgumentException::class);
334336 $ this ->expectExceptionMessage ('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources. ' );
335- $ process = $ this -> getProcess ( ' foo ' );
337+
336338 $ process ->setInput ($ value );
337339 }
338340
@@ -347,7 +349,7 @@ public static function provideInvalidInputValues()
347349 /**
348350 * @dataProvider provideInputValues
349351 */
350- public function testValidInput ($ expected , $ value )
352+ public function testValidInput (? string $ expected , null | float | string $ value )
351353 {
352354 $ process = $ this ->getProcess ('foo ' );
353355 $ process ->setInput ($ value );
@@ -593,8 +595,10 @@ public function testSuccessfulMustRunHasCorrectExitCode()
593595
594596 public function testMustRunThrowsException ()
595597 {
596- $ this ->expectException (ProcessFailedException::class);
597598 $ process = $ this ->getProcess ('exit 1 ' );
599+
600+ $ this ->expectException (ProcessFailedException::class);
601+
598602 $ process ->mustRun ();
599603 }
600604
@@ -972,9 +976,11 @@ public function testExitCodeIsAvailableAfterSignal()
972976
973977 public function testSignalProcessNotRunning ()
974978 {
979+ $ process = $ this ->getProcess ('foo ' );
980+
975981 $ this ->expectException (LogicException::class);
976982 $ this ->expectExceptionMessage ('Cannot send signal on a non running process. ' );
977- $ process = $ this -> getProcess ( ' foo ' );
983+
978984 $ process ->signal (1 ); // SIGHUP
979985 }
980986
@@ -1062,20 +1068,24 @@ public function testDisableOutputDisablesTheOutput()
10621068
10631069 public function testDisableOutputWhileRunningThrowsException ()
10641070 {
1065- $ this ->expectException (RuntimeException::class);
1066- $ this ->expectExceptionMessage ('Disabling output while the process is running is not possible. ' );
10671071 $ p = $ this ->getProcessForCode ('sleep(39); ' );
10681072 $ p ->start ();
1073+
1074+ $ this ->expectException (RuntimeException::class);
1075+ $ this ->expectExceptionMessage ('Disabling output while the process is running is not possible. ' );
1076+
10691077 $ p ->disableOutput ();
10701078 }
10711079
10721080 public function testEnableOutputWhileRunningThrowsException ()
10731081 {
1074- $ this ->expectException (RuntimeException::class);
1075- $ this ->expectExceptionMessage ('Enabling output while the process is running is not possible. ' );
10761082 $ p = $ this ->getProcessForCode ('sleep(40); ' );
10771083 $ p ->disableOutput ();
10781084 $ p ->start ();
1085+
1086+ $ this ->expectException (RuntimeException::class);
1087+ $ this ->expectExceptionMessage ('Enabling output while the process is running is not possible. ' );
1088+
10791089 $ p ->enableOutput ();
10801090 }
10811091
@@ -1091,19 +1101,23 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
10911101
10921102 public function testDisableOutputWhileIdleTimeoutIsSet ()
10931103 {
1094- $ this ->expectException (LogicException::class);
1095- $ this ->expectExceptionMessage ('Output cannot be disabled while an idle timeout is set. ' );
10961104 $ process = $ this ->getProcess ('foo ' );
10971105 $ process ->setIdleTimeout (1 );
1106+
1107+ $ this ->expectException (LogicException::class);
1108+ $ this ->expectExceptionMessage ('Output cannot be disabled while an idle timeout is set. ' );
1109+
10981110 $ process ->disableOutput ();
10991111 }
11001112
11011113 public function testSetIdleTimeoutWhileOutputIsDisabled ()
11021114 {
1103- $ this ->expectException (LogicException::class);
1104- $ this ->expectExceptionMessage ('timeout cannot be set while the output is disabled. ' );
11051115 $ process = $ this ->getProcess ('foo ' );
11061116 $ process ->disableOutput ();
1117+
1118+ $ this ->expectException (LogicException::class);
1119+ $ this ->expectExceptionMessage ('timeout cannot be set while the output is disabled. ' );
1120+
11071121 $ process ->setIdleTimeout (1 );
11081122 }
11091123
@@ -1119,11 +1133,13 @@ public function testSetNullIdleTimeoutWhileOutputIsDisabled()
11191133 */
11201134 public function testGetOutputWhileDisabled ($ fetchMethod )
11211135 {
1122- $ this ->expectException (LogicException::class);
1123- $ this ->expectExceptionMessage ('Output has been disabled. ' );
11241136 $ p = $ this ->getProcessForCode ('sleep(41); ' );
11251137 $ p ->disableOutput ();
11261138 $ p ->start ();
1139+
1140+ $ this ->expectException (LogicException::class);
1141+ $ this ->expectExceptionMessage ('Output has been disabled. ' );
1142+
11271143 $ p ->{$ fetchMethod }();
11281144 }
11291145
@@ -1523,17 +1539,21 @@ public function testPreparedCommandWithQuoteInIt()
15231539
15241540 public function testPreparedCommandWithMissingValue ()
15251541 {
1542+ $ p = Process::fromShellCommandline ('echo "${:abc}" ' );
1543+
15261544 $ this ->expectException (InvalidArgumentException::class);
15271545 $ this ->expectExceptionMessage ('Command line is missing a value for parameter "abc": echo "${:abc}" ' );
1528- $ p = Process:: fromShellCommandline ( ' echo "${:abc}" ' );
1546+
15291547 $ p ->run (null , ['bcd ' => 'BCD ' ]);
15301548 }
15311549
15321550 public function testPreparedCommandWithNoValues ()
15331551 {
1552+ $ p = Process::fromShellCommandline ('echo "${:abc}" ' );
1553+
15341554 $ this ->expectException (InvalidArgumentException::class);
15351555 $ this ->expectExceptionMessage ('Command line is missing a value for parameter "abc": echo "${:abc}" ' );
1536- $ p = Process:: fromShellCommandline ( ' echo "${:abc}" ' );
1556+
15371557 $ p ->run (null , []);
15381558 }
15391559
0 commit comments