Exemplo n.º 1
0
 /**
  * @test
  */
 public function isRestorableFromArray()
 {
     $arr = array('uuid' => 'lussutus-uuid', 'topic' => 'lussutusviesti', 'data' => array('lussutappa' => 'tussia'));
     $message = Message::fromArray($arr);
     $this->assertEquals($arr['data'], $message->getData());
     $this->assertEquals($arr['uuid'], $message->getUuid());
     $this->assertEquals($arr['topic'], $message->getTopic());
 }
Exemplo n.º 2
0
 /**
  * Dequeues message
  *
  * @return Message
  */
 public function dequeue()
 {
     $raw = $this->adapter->dequeue();
     if (!$raw) {
         return false;
     }
     list($json, $identifier, $internals) = $raw;
     $json = $this->inputFilters->filter($json);
     $json = json_decode($json, true);
     $serialized = SerializedData::fromJson($json['data']);
     $serializer = $this->dataSerializers->getUnserializerFor($serialized);
     if (!$serializer) {
         throw (new RuntimeException('Unserializer not found'))->setContext($raw);
     }
     $json['data'] = $serializer->unserialize($serialized->getData());
     $message = Message::fromArray($json);
     $message->setIdentifier($identifier);
     foreach ($internals as $key => $value) {
         $message->setInternal($key, $value);
     }
     return $message;
 }