Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Illuminate/Process/InvokedProcessPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Illuminate\Process;

class InvokedProcessPool
use Countable;

class InvokedProcessPool implements Countable
{
/**
* The array of invoked processes.
Expand Down Expand Up @@ -52,4 +54,14 @@ public function wait()
{
return new ProcessPoolResults(collect($this->invokedProcesses)->map->wait()->all());
}

/**
* Get the total number of processes.
*
* @return int
*/
public function count(): int
{
return count($this->invokedProcesses);
}
}
14 changes: 14 additions & 0 deletions tests/Process/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ public function testProcessPool()
$this->assertTrue(str_contains($results[1]->output(), 'ProcessTest.php'));
}

public function testInvokedProcessPoolCount()
{
$factory = new Factory;

$pool = $factory->pool(function ($pool) {
return [
$pool->path(__DIR__)->command($this->ls()),
$pool->path(__DIR__)->command($this->ls()),
];
})->start();

$this->assertCount(2, $pool);
}

public function testProcessPoolCanReceiveOutputForEachProcessViaStartMethod()
{
$factory = new Factory;
Expand Down