示例#1
0
 public function testDecodeFromString()
 {
     $format = $this->getFormatMock();
     $format->expects($this->any())->method('getNames')->will($this->returnValue(array('foo')));
     $format->expects($this->once())->method('decode')->will($this->returnCallback(function ($stream) {
         return stream_get_contents($stream);
     }));
     $encoder = new Encoder();
     $encoder->addFormat($format);
     $result = $encoder->decode('baz', 'foo', $this->getDefinitionMock());
     $this->assertSame('baz', $result);
 }
示例#2
0
 /**
  * @param  resource|string $stream
  * @param  string          $format
  * @param  string          $type
  * @param  array           $options
  * @param  mixed           $object
  * @return mixed
  */
 public function unserialize($stream, $format, $type, array $options = array(), &$object = null)
 {
     $definition = $this->resolver->getDefinition($type, $options);
     return $this->encoder->decode($stream, $format, $definition, $object);
 }