@@ -1541,6 +1541,60 @@ public function testEnvCaseInsensitiveOnWindows()
1541
1541
}
1542
1542
}
1543
1543
1544
+ public function testMultipleCallsToProcGetStatus ()
1545
+ {
1546
+ $ process = $ this ->getProcess ('echo foo ' );
1547
+ $ process ->start (static function () use ($ process ) {
1548
+ return $ process ->isRunning ();
1549
+ });
1550
+ while ($ process ->isRunning ()) {
1551
+ usleep (1000 );
1552
+ }
1553
+ $ this ->assertSame (0 , $ process ->getExitCode ());
1554
+ }
1555
+
1556
+ public function testFailingProcessWithMultipleCallsToProcGetStatus ()
1557
+ {
1558
+ $ process = $ this ->getProcess ('exit 123 ' );
1559
+ $ process ->start (static function () use ($ process ) {
1560
+ return $ process ->isRunning ();
1561
+ });
1562
+ while ($ process ->isRunning ()) {
1563
+ usleep (1000 );
1564
+ }
1565
+ $ this ->assertSame (123 , $ process ->getExitCode ());
1566
+ }
1567
+
1568
+ /**
1569
+ * @group slow
1570
+ */
1571
+ public function testLongRunningProcessWithMultipleCallsToProcGetStatus ()
1572
+ {
1573
+ $ process = $ this ->getProcess ('php -r "sleep(1); echo \'done \';" ' );
1574
+ $ process ->start (static function () use ($ process ) {
1575
+ return $ process ->isRunning ();
1576
+ });
1577
+ while ($ process ->isRunning ()) {
1578
+ usleep (1000 );
1579
+ }
1580
+ $ this ->assertSame (0 , $ process ->getExitCode ());
1581
+ }
1582
+
1583
+ /**
1584
+ * @group slow
1585
+ */
1586
+ public function testLongRunningProcessWithMultipleCallsToProcGetStatusError ()
1587
+ {
1588
+ $ process = $ this ->getProcess ('php -r "sleep(1); echo \'failure \'; exit(123);" ' );
1589
+ $ process ->start (static function () use ($ process ) {
1590
+ return $ process ->isRunning ();
1591
+ });
1592
+ while ($ process ->isRunning ()) {
1593
+ usleep (1000 );
1594
+ }
1595
+ $ this ->assertSame (123 , $ process ->getExitCode ());
1596
+ }
1597
+
1544
1598
/**
1545
1599
* @group transient-on-windows
1546
1600
*/
@@ -1556,7 +1610,6 @@ public function testNotTerminableInputPipe()
1556
1610
1557
1611
/**
1558
1612
* @param string|array $commandline
1559
- * @param mixed $input
1560
1613
*/
1561
1614
private function getProcess ($ commandline , ?string $ cwd = null , ?array $ env = null , $ input = null , ?int $ timeout = 60 ): Process
1562
1615
{
0 commit comments