/** * {@inheritDoc} */ public function all() { $workerIds = $this->adapter->all(); if (!is_array($workerIds)) { return array(); } /** @var WorkerInterface[] $instances */ $instances = array(); foreach ($workerIds as $workerId) { $instances[] = $this->workerFactory->createWorkerFromId($workerId); } return $instances; }
function it_fetches_all_registered_workers(WorkerRegistryAdapterInterface $adapter, WorkerFactoryInterface $workerFactory, WorkerInterface $workerRemote, WorkerInterface $workerLocal) { $adapter->all()->shouldBeCalled()->willReturn(array('remote:123', 'local:4556')); $workerFactory->createWorkerFromId('remote:123')->shouldBeCalled()->willReturn($workerRemote); $workerFactory->createWorkerFromId('local:4556')->shouldBeCalled()->willReturn($workerLocal); $this->all()->shouldReturn(array($workerRemote, $workerLocal)); }