Пример #1
0
 /**
  * Tests that we get an exception if we attempt to encode something that
  * is not serializable as JSON.
  * @expectedException Vectorface\SnappyRouter\Exception\EncoderException
  * @expectedExceptionMessage Unable to encode response as JSON.
  */
 public function testNonSerializableEncode()
 {
     $encoder = new JsonEncoder();
     $resource = fopen(__FILE__, 'r');
     // resources can't be serialized
     $encoder->encode(new Response($resource));
 }
Пример #2
0
 /**
  * @param AbstractResponse $response The response to be encoded.
  * @return Returns the response encoded in JSON.
  */
 public function encode(AbstractResponse $response)
 {
     return sprintf('%s(%s);', $this->clientMethod, parent::encode($response));
 }