Ejemplo n.º 1
0
 public function testEncodeAndReturn()
 {
     $format = $this->getFormatMock();
     $format->expects($this->any())->method('getNames')->will($this->returnValue(array('foo')));
     $format->expects($this->once())->method('encode')->will($this->returnCallback(function ($origin, $definition, $stream) {
         fputs($stream, "bar");
     }));
     $encoder = new Encoder();
     $encoder->addFormat($format);
     $content = $encoder->encode(null, $this->getDefinitionMock(), false, 'foo');
     $this->assertEquals('bar', $content);
 }
Ejemplo n.º 2
0
 /**
  * @param  mixed         $object
  * @param  string        $type
  * @param  resource|bool $stream
  * @param  string        $format
  * @param  array         $options
  * @return string|bool
  */
 public function serialize($object, $type, $stream, $format, array $options = array())
 {
     $definition = $this->resolver->getDefinition($type, $options);
     return $this->encoder->encode($object, $definition, $stream, $format);
 }