/** * Tests basic operations. */ public function testBasicOperations() { $this->assertTrue($this->storage->add('value', 'id')); $this->assertTrue($this->storage->containsId('id')); $this->assertEquals('value', $this->storage->findById('id')); $this->storage->add('another-value'); $this->assertTrue($this->storage->contains('another-value')); $this->assertTrue($this->storage->remove('another-value')); $this->assertFalse($this->storage->contains('another-value')); }
/** * 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; }