/** * Tests all() method. */ public function testAll() { $this->assertTrue($this->storage->add('value', 'id')); $this->assertCount(1, $this->storage->all()); $this->assertTrue($this->storage->removeById('id')); $this->assertFalse($this->storage->containsId('id')); $this->assertCount(0, $this->storage->all()); }
/** * Merges local storage with global storage. * * @param StorageInterface $storage Local storage */ protected function mergeStorage(StorageInterface $storage) { foreach ($storage->all() as $id => $object) { $this->stack->getScope('global')->add($object); } }
/** * Handles worker. * * @param WorkerInterface $worker Worker * @param mixed $object Object to handle * @param StorageInterface $storage Associated storage */ protected function handleWorker(WorkerInterface $worker, $object, StorageInterface $storage) { $this->injectDependencies($worker); $modifiedObject = $worker->handle($object); if ($modifiedObject === null) { $storage->remove($object); } elseif ($modifiedObject !== $object) { $storage->remove($object); $storage->add($modifiedObject); } return $modifiedObject; }