Skip to content

Commit

Permalink
[Core] Accessible to process instance from fork
Browse files Browse the repository at this point in the history
  • Loading branch information
khaperets committed Feb 13, 2018
1 parent ec995b5 commit a7ea96a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Fork/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public function __construct(ProcessInterface $process = null)
$this->process = $process;
}

/**
* {@inheritdoc}
*/
public function getProcess(): ProcessInterface
{
return $this->process;
}

/**
* {@inheritdoc}
*/
Expand Down
7 changes: 7 additions & 0 deletions Fork/ForkInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@ public function each(): \Closure;
* @return ProcessInterface
*/
public function run(int $processesCount = ProcessInterface::AUTO_DETECT_OF_PROCESSES_QUANTITY): ProcessInterface;

/**
* Returns the ProcessInterface instance.
*
* @return ProcessInterface
*/
public function getProcess(): ProcessInterface;
}
3 changes: 3 additions & 0 deletions Tests/Fork/ForkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testTasksExecuting()

$process->method('fork')->willReturn(true);

$pid = $process->getPid();
$fork = new Fork\Fork($process);

$fork
Expand All @@ -50,5 +51,7 @@ public function testTasksExecuting()
$this->assertTrue($task1->isExecuted());
$this->assertTrue($task2->isExecuted());
$this->assertTrue($task3->isExecuted());

$this->assertSame($pid, $fork->getProcess()->getPid());
}
}

0 comments on commit a7ea96a

Please sign in to comment.