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 2
2
3
3
namespace Illuminate \Process ;
4
4
5
- class InvokedProcessPool
5
+ use Countable ;
6
+
7
+ class InvokedProcessPool implements Countable
6
8
{
7
9
/**
8
10
* The array of invoked processes.
@@ -52,4 +54,14 @@ public function wait()
52
54
{
53
55
return new ProcessPoolResults (collect ($ this ->invokedProcesses )->map ->wait ()->all ());
54
56
}
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
+ }
55
67
}
Original file line number Diff line number Diff line change @@ -54,6 +54,20 @@ public function testProcessPool()
54
54
$ this ->assertTrue (str_contains ($ results [1 ]->output (), 'ProcessTest.php ' ));
55
55
}
56
56
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
+
57
71
public function testProcessPoolCanReceiveOutputForEachProcessViaStartMethod ()
58
72
{
59
73
$ factory = new Factory ;
You can’t perform that action at this time.
0 commit comments