/** * @test */ public function shouldSpawnACallable() { $sumAndPrint = function ($sum) { foreach (range(1, $sum) as $i) { echo "{$i}"; $sum += $i; } return $sum; }; $spawn = new Spawn(); $process = $spawn->spawn(10, $sumAndPrint); $process->wait(); $this->assertEquals(null, $process->getErrorOutput()); $this->assertEquals(65, $process->getReturnValue()); $this->assertEquals('12345678910', $process->getOutput()); }