public function testSetParams()
 {
     $params = array('foo' => 'bar');
     $payload = new Payload();
     $this->assertSame(array(), $payload->getParams());
     $payload->setParams($params);
     $this->assertSame($params, $payload->getParams());
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  * @see \InoPerunApi\Client\Serializer\SerializerInterface::unserialize()
  */
 public function unserialize($data, Payload $payload)
 {
     try {
         $params = $this->jsonDecode($data);
     } catch (\Exception $e) {
         throw new Exception\UnserializeException(sprintf("JSON decode exception: [%s] %s", get_class($e), $e->getMessage()));
     }
     if (null !== $params) {
         if (is_array($params)) {
             $payload->setParams($params);
         } else {
             throw new Exception\UnexpectedResultException('Invalid unserialized data - must be array or null');
         }
     }
     return $payload;
 }