Esempio n. 1
0
 protected function serializeResult($result)
 {
     if ($result instanceof PromiseInterface) {
         return $result->getId();
     }
     try {
         $resultJson = JsonCoder::jsonSerialize($result);
     } catch (PromiseException $ex) {
         $class = is_object($result) ? 'for object ' . get_class($result) : '';
         throw new PromiseException("Cannot serialize result " . $class, 0, $ex);
     }
     return $resultJson;
 }
Esempio n. 2
0
 public function testJsonCoder_ExceptionJsonSerialize()
 {
     $e1 = new PromiseException('Exception1', 1);
     $e11 = new PromiseException('Exception11', 11, $e1);
     $this->assertEquals($e11, JsonCoder::jsonUnserialize(JsonCoder::jsonSerialize($e11)));
 }