public function testManagerReady() { $function = null; $message = Factory::rpc('beer', ['foo' => 'bar']); $worker = Phake::mock('WyriHaximus\\React\\ChildProcess\\Pool\\WorkerInterface'); $queue = Phake::mock('WyriHaximus\\React\\ChildProcess\\Pool\\QueueInterface'); $manager = Phake::mock('WyriHaximus\\React\\ChildProcess\\Pool\\ManagerInterface'); Phake::when($queue)->count()->thenReturn(4); Phake::when($queue)->dequeue()->thenReturn($message); Phake::when($manager)->on($this->isType('string'), $this->isType('callable'))->thenReturnCallback(function ($event, $passedFunction) use(&$function) { $function = $passedFunction; }); $poolInstance = null; $process = Phake::mock('React\\ChildProcess\\Process'); $loop = Phake::mock('React\\EventLoop\\LoopInterface'); Fixed::create($process, $loop, [Options::MANAGER => $manager, Options::QUEUE => $queue])->then(function ($pool) use($message) { $pool->rpc($message); }); $function($worker); Phake::verify($worker)->rpc($message); }
/** * @expectedException \Exception * @expectedExceptionMessage Given class doesn't implement ChildInterface */ public function testCreateFromClass() { $loop = Phake::mock('React\\EventLoop\\LoopInterface'); Fixed::createFromClass('stdClass', $loop); }