File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 22
33namespace Illuminate \Process ;
44
5- class InvokedProcessPool
5+ use Countable ;
6+
7+ class InvokedProcessPool implements Countable
68{
79 /**
810 * The array of invoked processes.
@@ -52,4 +54,14 @@ public function wait()
5254 {
5355 return new ProcessPoolResults (collect ($ this ->invokedProcesses )->map ->wait ()->all ());
5456 }
57+
58+ /**
59+ * Get the total number of processes.
60+ *
61+ * @return int
62+ */
63+ public function count (): int
64+ {
65+ return count ($ this ->invokedProcesses );
66+ }
5567}
Original file line number Diff line number Diff line change @@ -54,6 +54,20 @@ public function testProcessPool()
5454 $ this ->assertTrue (str_contains ($ results [1 ]->output (), 'ProcessTest.php ' ));
5555 }
5656
57+ public function testInvokedProcessPoolCount ()
58+ {
59+ $ factory = new Factory ;
60+
61+ $ pool = $ factory ->pool (function ($ pool ) {
62+ return [
63+ $ pool ->path (__DIR__ )->command ($ this ->ls ()),
64+ $ pool ->path (__DIR__ )->command ($ this ->ls ()),
65+ ];
66+ })->start ();
67+
68+ $ this ->assertCount (2 , $ pool );
69+ }
70+
5771 public function testProcessPoolCanReceiveOutputForEachProcessViaStartMethod ()
5872 {
5973 $ factory = new Factory ;
You can’t perform that action at this time.
0 commit comments