/** * Handle the message to retrieve the cached content from the injected cache proxy. * @param \Brickoo\Component\Messaging\Message $message * @return mixed the cached content otherwise null */ public function handleRetrieveMessage(Message $message) { if ($message instanceof RetrieveMessage) { return $this->storageProxy->get($message->getIdentifier()); } return null; }
/** * @covers Brickoo\Component\Storage\StorageProxy::get * @covers Brickoo\Component\Storage\StorageProxy::getAdapter * @covers Brickoo\Component\Storage\StorageProxy::getReadyAdapter * @covers Brickoo\Component\Storage\StorageProxy::executeIterationCallback */ public function testGetAdapterUsesFirstReadyAdapter() { $storageIdentifier = "someId"; $storageContent = "some content"; $adapterExpected = $this->getAdapterStub(); $adapterExpected->expects($this->once())->method("get")->with($storageIdentifier)->will($this->returnValue($storageContent)); $adapterUnexpected = $this->getAdapterStub(); $storageProxy = new StorageProxy($this->getAdapterPoolIterator([$adapterExpected, $adapterUnexpected])); $this->assertEquals($storageContent, $storageProxy->get($storageIdentifier)); }