@@ -328,11 +328,13 @@ public function testSetInputWhileRunningThrowsAnException()
328
328
/**
329
329
* @dataProvider provideInvalidInputValues
330
330
*/
331
- public function testInvalidInput ($ value )
331
+ public function testInvalidInput (array | object $ value )
332
332
{
333
+ $ process = $ this ->getProcess ('foo ' );
334
+
333
335
$ this ->expectException (InvalidArgumentException::class);
334
336
$ this ->expectExceptionMessage ('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources. ' );
335
- $ process = $ this -> getProcess ( ' foo ' );
337
+
336
338
$ process ->setInput ($ value );
337
339
}
338
340
@@ -347,7 +349,7 @@ public static function provideInvalidInputValues()
347
349
/**
348
350
* @dataProvider provideInputValues
349
351
*/
350
- public function testValidInput ($ expected , $ value )
352
+ public function testValidInput (? string $ expected , null | float | string $ value )
351
353
{
352
354
$ process = $ this ->getProcess ('foo ' );
353
355
$ process ->setInput ($ value );
@@ -593,8 +595,10 @@ public function testSuccessfulMustRunHasCorrectExitCode()
593
595
594
596
public function testMustRunThrowsException ()
595
597
{
596
- $ this ->expectException (ProcessFailedException::class);
597
598
$ process = $ this ->getProcess ('exit 1 ' );
599
+
600
+ $ this ->expectException (ProcessFailedException::class);
601
+
598
602
$ process ->mustRun ();
599
603
}
600
604
@@ -972,9 +976,11 @@ public function testExitCodeIsAvailableAfterSignal()
972
976
973
977
public function testSignalProcessNotRunning ()
974
978
{
979
+ $ process = $ this ->getProcess ('foo ' );
980
+
975
981
$ this ->expectException (LogicException::class);
976
982
$ this ->expectExceptionMessage ('Cannot send signal on a non running process. ' );
977
- $ process = $ this -> getProcess ( ' foo ' );
983
+
978
984
$ process ->signal (1 ); // SIGHUP
979
985
}
980
986
@@ -1062,20 +1068,24 @@ public function testDisableOutputDisablesTheOutput()
1062
1068
1063
1069
public function testDisableOutputWhileRunningThrowsException ()
1064
1070
{
1065
- $ this ->expectException (RuntimeException::class);
1066
- $ this ->expectExceptionMessage ('Disabling output while the process is running is not possible. ' );
1067
1071
$ p = $ this ->getProcessForCode ('sleep(39); ' );
1068
1072
$ p ->start ();
1073
+
1074
+ $ this ->expectException (RuntimeException::class);
1075
+ $ this ->expectExceptionMessage ('Disabling output while the process is running is not possible. ' );
1076
+
1069
1077
$ p ->disableOutput ();
1070
1078
}
1071
1079
1072
1080
public function testEnableOutputWhileRunningThrowsException ()
1073
1081
{
1074
- $ this ->expectException (RuntimeException::class);
1075
- $ this ->expectExceptionMessage ('Enabling output while the process is running is not possible. ' );
1076
1082
$ p = $ this ->getProcessForCode ('sleep(40); ' );
1077
1083
$ p ->disableOutput ();
1078
1084
$ p ->start ();
1085
+
1086
+ $ this ->expectException (RuntimeException::class);
1087
+ $ this ->expectExceptionMessage ('Enabling output while the process is running is not possible. ' );
1088
+
1079
1089
$ p ->enableOutput ();
1080
1090
}
1081
1091
@@ -1091,19 +1101,23 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
1091
1101
1092
1102
public function testDisableOutputWhileIdleTimeoutIsSet ()
1093
1103
{
1094
- $ this ->expectException (LogicException::class);
1095
- $ this ->expectExceptionMessage ('Output cannot be disabled while an idle timeout is set. ' );
1096
1104
$ process = $ this ->getProcess ('foo ' );
1097
1105
$ process ->setIdleTimeout (1 );
1106
+
1107
+ $ this ->expectException (LogicException::class);
1108
+ $ this ->expectExceptionMessage ('Output cannot be disabled while an idle timeout is set. ' );
1109
+
1098
1110
$ process ->disableOutput ();
1099
1111
}
1100
1112
1101
1113
public function testSetIdleTimeoutWhileOutputIsDisabled ()
1102
1114
{
1103
- $ this ->expectException (LogicException::class);
1104
- $ this ->expectExceptionMessage ('timeout cannot be set while the output is disabled. ' );
1105
1115
$ process = $ this ->getProcess ('foo ' );
1106
1116
$ process ->disableOutput ();
1117
+
1118
+ $ this ->expectException (LogicException::class);
1119
+ $ this ->expectExceptionMessage ('timeout cannot be set while the output is disabled. ' );
1120
+
1107
1121
$ process ->setIdleTimeout (1 );
1108
1122
}
1109
1123
@@ -1119,11 +1133,13 @@ public function testSetNullIdleTimeoutWhileOutputIsDisabled()
1119
1133
*/
1120
1134
public function testGetOutputWhileDisabled ($ fetchMethod )
1121
1135
{
1122
- $ this ->expectException (LogicException::class);
1123
- $ this ->expectExceptionMessage ('Output has been disabled. ' );
1124
1136
$ p = $ this ->getProcessForCode ('sleep(41); ' );
1125
1137
$ p ->disableOutput ();
1126
1138
$ p ->start ();
1139
+
1140
+ $ this ->expectException (LogicException::class);
1141
+ $ this ->expectExceptionMessage ('Output has been disabled. ' );
1142
+
1127
1143
$ p ->{$ fetchMethod }();
1128
1144
}
1129
1145
@@ -1523,17 +1539,21 @@ public function testPreparedCommandWithQuoteInIt()
1523
1539
1524
1540
public function testPreparedCommandWithMissingValue ()
1525
1541
{
1542
+ $ p = Process::fromShellCommandline ('echo "${:abc}" ' );
1543
+
1526
1544
$ this ->expectException (InvalidArgumentException::class);
1527
1545
$ this ->expectExceptionMessage ('Command line is missing a value for parameter "abc": echo "${:abc}" ' );
1528
- $ p = Process:: fromShellCommandline ( ' echo "${:abc}" ' );
1546
+
1529
1547
$ p ->run (null , ['bcd ' => 'BCD ' ]);
1530
1548
}
1531
1549
1532
1550
public function testPreparedCommandWithNoValues ()
1533
1551
{
1552
+ $ p = Process::fromShellCommandline ('echo "${:abc}" ' );
1553
+
1534
1554
$ this ->expectException (InvalidArgumentException::class);
1535
1555
$ this ->expectExceptionMessage ('Command line is missing a value for parameter "abc": echo "${:abc}" ' );
1536
- $ p = Process:: fromShellCommandline ( ' echo "${:abc}" ' );
1556
+
1537
1557
$ p ->run (null , []);
1538
1558
}
1539
1559
0 commit comments