Browse Source

Merge remote branch 'lsmith77/serializer_tweaks'

* lsmith77/serializer_tweaks: (22 commits)
  clarified that BC is broken in the Serializer component
  added UPDATE notes for Serializer component changes
  fix tests
  marked public api
  more encoder lazy loading tweaks
  always use getEncoder() to enable lazy loading
  cosmetic tweak
  removed setEncoder/removeEncoder/addNormalizer/removeNormalizer
  SerializerAwareInterface and DecoderInterface do not implement EncoderInterface anymore
  handle non objects
  moved the methods that can later be moved to a Builder to the bottom
  use getEncoder inside encode/decode
  made serialize/deserialize/encode/decode final
  added Constructor
  added Exception's from SerializerBundle
  made (de)normalizeObject() private
  renamed hasEncoder/hasDecoder to supportsSerialization/supportsDeserialization
  notice fixes
  typo fixes
  all encoders implement EncoderInterface
  ...
Fabien Potencier 14 năm trước cách đây
mục cha
commit
37cd020040

+ 4 - 0
UPDATE.md

@@ -9,6 +9,10 @@ timeline closely anyway.
 beta4 to beta5
 --------------
 
+* Expanded the SerializerInterface, while reducing the number of public
+  methods in the Serializer class itself breaking BC and adding component
+  specific Exception classes.
+
 * The temporary storage for file uploads has been removed
 
 * The `Symfony\Component\HttpFoundation\File\File::getExtension()` and

+ 1 - 1
src/Symfony/Component/Serializer/Encoder/SerializerAwareEncoder.php

@@ -19,7 +19,7 @@ use Symfony\Component\Serializer\SerializerAwareInterface;
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
  */
-abstract class SerializerAwareEncoder implements SerializerAwareInterface, EncoderInterface
+abstract class SerializerAwareEncoder implements SerializerAwareInterface
 {
     protected $serializer;
 

+ 5 - 4
src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

@@ -3,6 +3,7 @@
 namespace Symfony\Component\Serializer\Encoder;
 
 use Symfony\Component\Serializer\SerializerInterface;
+use Symfony\Component\Serializer\Exception\UnexpectedValueException;
 
 /*
  * This file is part of the Symfony framework.
@@ -20,7 +21,7 @@ use Symfony\Component\Serializer\SerializerInterface;
  * @author John Wards <jwards@whiteoctober.co.uk>
  * @author Fabian Vogler <fabian@equivalence.ch>
  */
-class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, NormalizationAwareInterface
+class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface
 {
     private $dom;
     private $format;
@@ -254,7 +255,7 @@ class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, Nor
             return $append;
         }
         if (is_object($data)) {
-            $data = $this->serializer->normalizeObject($data, $this->format);
+            $data = $this->serializer->normalize($data, $this->format);
             if (null !== $data && !is_scalar($data)) {
                 return $this->buildXml($parentNode, $data);
             }
@@ -268,7 +269,7 @@ class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, Nor
 
             return $this->appendNode($parentNode, $data, 'data');
         }
-        throw new \UnexpectedValueException('An unexpected value could not be serialized: '.var_export($data, true));
+        throw new UnexpectedValueException('An unexpected value could not be serialized: '.var_export($data, true));
     }
 
     /**
@@ -312,7 +313,7 @@ class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, Nor
         } elseif ($val instanceof \Traversable) {
             $this->buildXml($node, $val);
         } elseif (is_object($val)) {
-            return $this->buildXml($node, $this->serializer->normalizeObject($val, $this->format));
+            return $this->buildXml($node, $this->serializer->normalize($val, $this->format));
         } elseif (is_numeric($val)) {
             return $this->appendText($node, (string) $val);
         } elseif (is_string($val)) {

+ 21 - 0
src/Symfony/Component/Serializer/Exception/Exception.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * Base exception
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface Exception
+{
+}

+ 21 - 0
src/Symfony/Component/Serializer/Exception/InvalidArgumentException.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * InvalidArgumentException
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class InvalidArgumentException extends \InvalidArgumentException implements Exception
+{
+}

+ 21 - 0
src/Symfony/Component/Serializer/Exception/LogicException.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * LogicException
+ *
+ * @author Lukas Kahwe Smith <smith@pooteeweet.org>
+ */
+class LogicException extends \LogicException implements Exception
+{
+}

+ 21 - 0
src/Symfony/Component/Serializer/Exception/RuntimeException.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * RuntimeException
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class RuntimeException extends \RuntimeException implements Exception
+{
+}

+ 21 - 0
src/Symfony/Component/Serializer/Exception/UnexpectedValueException.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * UnexpectedValueException
+ *
+ * @author Lukas Kahwe Smith <smith@pooteeweet.org>
+ */
+class UnexpectedValueException extends \UnexpectedValueException implements Exception
+{
+}

+ 21 - 0
src/Symfony/Component/Serializer/Exception/UnsupportedException.php

@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Symfony\Component\Serializer\Exception;
+
+/**
+ * UnsupportedException
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class UnsupportedException extends InvalidArgumentException
+{
+}

+ 3 - 2
src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

@@ -3,6 +3,7 @@
 namespace Symfony\Component\Serializer\Normalizer;
 
 use Symfony\Component\Serializer\SerializerInterface;
+use Symfony\Component\Serializer\Exception\RuntimeException;
 
 /*
  * This file is part of the Symfony framework.
@@ -80,7 +81,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
                     // don't run set for a parameter passed to the constructor
                     unset($data[$paramName]);
                 } else if (!$constructorParameter->isOptional()) {
-                    throw new \RuntimeException(
+                    throw new RuntimeException(
                         'Cannot create an instance of ' . $class .
                         ' from serialized data because its constructor requires ' .
                         'parameter "' . $constructorParameter->getName() .
@@ -108,7 +109,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
      */
     public function supportsNormalization($data, $format = null)
     {
-        return $this->supports(get_class($data));
+        return is_object($data) && $this->supports(get_class($data));
     }
 
     /**

+ 80 - 122
src/Symfony/Component/Serializer/Serializer.php

@@ -6,6 +6,9 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
 use Symfony\Component\Serializer\Encoder\EncoderInterface;
 use Symfony\Component\Serializer\Encoder\DecoderInterface;
 use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
+use Symfony\Component\Serializer\Exception\RuntimeException;
+use Symfony\Component\Serializer\Exception\LogicException;
+use Symfony\Component\Serializer\Exception\UnexpectedValueException;
 
 /*
  * This file is part of the Symfony framework.
@@ -24,27 +27,48 @@ use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
  *
  * $serializer->serialize($obj, 'xml')
  * $serializer->decode($data, 'xml')
- * $serializer->denormalizeObject($data, 'Class', 'xml')
+ * $serializer->denormalize($data, 'Class', 'xml')
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Lukas Kahwe Smith <smith@pooteeweet.org>
  */
 class Serializer implements SerializerInterface
 {
-    private $normalizers = array();
-    private $encoders = array();
-    private $decoders = array();
+    protected $normalizers = array();
+    protected $encoders = array();
     protected $normalizerCache = array();
     protected $denormalizerCache = array();
 
+    public function __construct(array $normalizers = array(), array $encoders = array())
+    {
+        foreach ($normalizers as $normalizer) {
+            if ($normalizer instanceof SerializerAwareInterface) {
+                $normalizer->setSerializer($this);
+            }
+        }
+        $this->normalizers = $normalizers;
+
+        foreach ($encoders as $encoder) {
+            if ($encoder instanceof SerializerAwareInterface) {
+                $encoder->setSerializer($this);
+            }
+        }
+        $this->encoders = $encoders;
+    }
+
     /**
      * {@inheritdoc}
      */
-    public function serialize($data, $format)
+    public final function serialize($data, $format)
     {
-        if (!isset($this->encoders[$format])) {
-            throw new \UnexpectedValueException('No encoder registered for the '.$format.' format');
+        if (!$this->supportsSerialization($format)) {
+            throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported');
         }
-        if (!$this->encoders[$format] instanceof NormalizationAwareInterface) {
+
+        $encoder = $this->getEncoder($format);
+
+        if (!$encoder instanceof NormalizationAwareInterface) {
             $data = $this->normalize($data);
         }
 
@@ -52,10 +76,17 @@ class Serializer implements SerializerInterface
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
-    public function deserialize($data, $type, $format) {
-        return $this->denormalize($this->decode($data, $format), $type, $format);
+    public final function deserialize($data, $type, $format)
+    {
+        if (!$this->supportsDeserialization($format)) {
+            throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported');
+        }
+
+        $data = $this->decode($data, $format);
+
+        return $this->denormalize($data, $type, $format);
     }
 
     /**
@@ -84,11 +115,11 @@ class Serializer implements SerializerInterface
 
             return $data;
         }
-        throw new \UnexpectedValueException('An unexpected value could not be normalized: '.var_export($data, true));
+        throw new UnexpectedValueException('An unexpected value could not be normalized: '.var_export($data, true));
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
     public function denormalize($data, $type, $format = null)
     {
@@ -98,25 +129,17 @@ class Serializer implements SerializerInterface
     /**
      * {@inheritdoc}
      */
-    public function encode($data, $format)
+    public final function encode($data, $format)
     {
-        if (!isset($this->encoders[$format])) {
-            throw new \UnexpectedValueException('No encoder registered for the '.$format.' format');
-        }
-
-        return $this->encoders[$format]->encode($data, $format);
+        return $this->getEncoder($format)->encode($data, $format);
     }
 
     /**
      * {@inheritdoc}
      */
-    public function decode($data, $format)
+    public final function decode($data, $format)
     {
-        if (!isset($this->decoders[$format])) {
-            throw new \UnexpectedValueException('No decoder registered for the '.$format.' format');
-        }
-
-        return $this->decoders[$format]->decode($data, $format);
+        return $this->getEncoder($format)->decode($data, $format);
     }
 
     /**
@@ -126,10 +149,10 @@ class Serializer implements SerializerInterface
      * @param string $format format name, present to give the option to normalizers to act differently based on formats
      * @return array|scalar
      */
-    public function normalizeObject($object, $format = null)
+    private function normalizeObject($object, $format = null)
     {
         if (!$this->normalizers) {
-            throw new \LogicException('You must register at least one normalizer to be able to normalize objects.');
+            throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
         }
         $class = get_class($object);
         if (isset($this->normalizerCache[$class][$format])) {
@@ -142,7 +165,7 @@ class Serializer implements SerializerInterface
                 return $normalizer->normalize($object, $format);
             }
         }
-        throw new \UnexpectedValueException('Could not normalize object of type '.$class.', no supporting normalizer found.');
+        throw new UnexpectedValueException('Could not normalize object of type '.$class.', no supporting normalizer found.');
     }
 
     /**
@@ -153,10 +176,10 @@ class Serializer implements SerializerInterface
      * @param string $format format name, present to give the option to normalizers to act differently based on formats
      * @return object
      */
-    public function denormalizeObject($data, $class, $format = null)
+    private function denormalizeObject($data, $class, $format = null)
     {
         if (!$this->normalizers) {
-            throw new \LogicException('You must register at least one normalizer to be able to denormalize objects.');
+            throw new LogicException('You must register at least one normalizer to be able to denormalize objects.');
         }
         if (isset($this->denormalizerCache[$class][$format])) {
             return $this->denormalizerCache[$class][$format]->denormalize($data, $class, $format);
@@ -168,127 +191,62 @@ class Serializer implements SerializerInterface
                 return $normalizer->denormalize($data, $class, $format);
             }
         }
-        throw new \UnexpectedValueException('Could not denormalize object of type '.$class.', no supporting normalizer found.');
-    }
-
-    /**
-     * @param NormalizerInterface $normalizer
-     */
-    public function addNormalizer(NormalizerInterface $normalizer)
-    {
-        $this->normalizers[] = $normalizer;
-        if ($normalizer instanceof SerializerAwareInterface) {
-            $normalizer->setSerializer($this);
-        }
+        throw new UnexpectedValueException('Could not denormalize object of type '.$class.', no supporting normalizer found.');
     }
 
     /**
-     * @return array[]NormalizerInterface
+     * {@inheritdoc}
      */
-    public function getNormalizers()
+    public function supportsSerialization($format)
     {
-        return $this->normalizers;
+        return $this->supportsEncoding($format);
     }
 
     /**
-     * @param NormalizerInterface $normalizer
+     * {@inheritdoc}
      */
-    public function removeNormalizer(NormalizerInterface $normalizer)
+    public function supportsDeserialization($format)
     {
-        unset($this->normalizers[array_search($normalizer, $this->normalizers, true)]);
+        return $this->supportsDecoding($format);
     }
 
     /**
-     * @param string           $format  format name
-     * @param EncoderInterface $encoder
+     * {@inheritdoc}
      */
-    public function setEncoder($format, EncoderInterface $encoder)
+    public function supportsEncoding($format)
     {
-        $this->encoders[$format] = $encoder;
-        if ($encoder instanceof SerializerAwareInterface) {
-            $encoder->setSerializer($this);
+        try {
+            $encoder = $this->getEncoder($format);
+        } catch (\RuntimeException $e) {
+            return false;
         }
-    }
 
-    /**
-     * @param string           $format  format name
-     * @param DecoderInterface $decoder
-     */
-    public function setDecoder($format, DecoderInterface $decoder)
-    {
-        $this->decoders[$format] = $decoder;
-        if ($decoder instanceof SerializerAwareInterface) {
-            $decoder->setSerializer($this);
-        }
+        return $encoder instanceof EncoderInterface;
     }
 
     /**
-     * @return array[]EncoderInterface
+     * {@inheritdoc}
      */
-    public function getEncoders()
+    public function supportsDecoding($format)
     {
-        return $this->encoders;
-    }
+        try {
+            $encoder = $this->getEncoder($format);
+        } catch (\RuntimeException $e) {
+            return false;
+        }
 
-    /**
-     * @return array[]DecoderInterface
-     */
-    public function getDecoders()
-    {
-        return $this->decoders;
+        return $encoder instanceof DecoderInterface;
     }
 
     /**
-     * @return EncoderInterface
+     * {@inheritdoc}
      */
     public function getEncoder($format)
     {
-        return $this->encoders[$format];
-    }
-
-    /**
-     * @return DecoderInterface
-     */
-    public function getDecoder($format)
-    {
-        return $this->decoders[$format];
-    }
-
-    /**
-     * Checks whether the serializer has an encoder registered for the given format
-     *
-     * @param string $format format name
-     * @return Boolean
-     */
-    public function hasEncoder($format)
-    {
-        return isset($this->encoders[$format]);
-    }
-
-    /**
-     * Checks whether the serializer has a decoder registered for the given format
-     *
-     * @param string $format format name
-     * @return Boolean
-     */
-    public function hasDecoder($format)
-    {
-        return isset($this->decoders[$format]);
-    }
-
-    /**
-     * @param string $format format name
-     */
-    public function removeEncoder($format)
-    {
-        unset($this->encoders[$format]);
-    }
+        if (!isset($this->encoders[$format])) {
+            throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
+        }
 
-    /**
-     * @param string $format format name
-     */
-    public function removeDecoder($format)
-    {
-        unset($this->decoders[$format]);
+        return $this->encoders[$format];
     }
 }

+ 49 - 2
src/Symfony/Component/Serializer/SerializerInterface.php

@@ -2,8 +2,10 @@
 
 namespace Symfony\Component\Serializer;
 
-use Symfony\Component\Serializer\Encoder\EncoderInterface;
 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
+use Symfony\Component\Serializer\Encoder\EncoderInterface;
+use Symfony\Component\Serializer\Encoder\DecoderInterface;
+use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
 
 /*
  * This file is part of the Symfony framework.
@@ -37,6 +39,7 @@ interface SerializerInterface
      * @param mixed $data
      * @param string $type
      * @param string $format
+     * @api
      */
     function deserialize($data, $type, $format);
 
@@ -56,8 +59,8 @@ interface SerializerInterface
      * @param mixed $data
      * @param string $type
      * @param string $format
-     *
      * @return mixed
+     * @api
      */
     function denormalize($data, $type, $format = null);
 
@@ -80,4 +83,48 @@ interface SerializerInterface
      * @api
      */
     function decode($data, $format);
+
+    /**
+     * Checks whether the serializer can serialize to given format
+     *
+     * @param string $format format name
+     * @return Boolean
+     * @api
+     */
+    function supportsSerialization($format);
+
+    /**
+     * Checks whether the serializer can deserialize from given format
+     *
+     * @param string $format format name
+     * @return Boolean
+     * @api
+     */
+    function supportsDeserialization($format);
+
+    /**
+     * Checks whether the serializer can encode to given format
+     *
+     * @param string $format format name
+     * @return Boolean
+     * @api
+     */
+    function supportsEncoding($format);
+
+    /**
+     * Checks whether the serializer can decode from given format
+     *
+     * @param string $format format name
+     * @return Boolean
+     * @api
+     */
+    function supportsDecoding($format);
+
+    /**
+     * Get the encoder for the given format
+     * 
+     * @return EncoderInterface
+     * @api
+     */
+    function getEncoder($format);
 }

+ 2 - 3
tests/Symfony/Tests/Component/Serializer/Encoder/XmlEncoderTest.php

@@ -24,10 +24,9 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
 {
     public function setUp()
     {
-        $serializer = new Serializer;
         $this->encoder = new XmlEncoder;
-        $serializer->setEncoder('xml', $this->encoder);
-        $serializer->addNormalizer(new CustomNormalizer);
+        $serializer = new Serializer(array(new CustomNormalizer), array('xml' => new XmlEncoder()));
+        $this->encoder->setSerializer($serializer);
     }
 
     public function testEncodeScalar()

+ 10 - 24
tests/Symfony/Tests/Component/Serializer/SerializerTest.php

@@ -17,39 +17,34 @@ use Symfony\Component\Serializer\Encoder\JsonEncoder;
 
 class SerializerTest extends \PHPUnit_Framework_TestCase
 {
-    public function setUp()
-    {
-        $this->serializer = new Serializer();
-    }
-
     /**
      * @expectedException \UnexpectedValueException
      */
-    public function testNormalizeObjectNoMatch()
+    public function testNormalizeNoMatch()
     {
-        $this->serializer->addNormalizer($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer'));
-        $this->serializer->normalizeObject(new \stdClass, 'xml');
+        $this->serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
+        $this->serializer->normalize(new \stdClass, 'xml');
     }
 
     /**
      * @expectedException \UnexpectedValueException
      */
-    public function testDenormalizeObjectNoMatch()
+    public function testDenormalizeNoMatch()
     {
-        $this->serializer->addNormalizer($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer'));
-        $this->serializer->denormalizeObject('foo', 'stdClass');
+        $this->serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
+        $this->serializer->denormalize('foo', 'stdClass');
     }
 
     public function testSerializeScalar()
     {
-        $this->serializer->setEncoder('json', new JsonEncoder());
+        $this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
         $result = $this->serializer->serialize('foo', 'json');
         $this->assertEquals('"foo"', $result);
     }
 
     public function testSerializeArrayOfScalars()
     {
-        $this->serializer->setEncoder('json', new JsonEncoder());
+        $this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
         $data = array('foo', array(5, 3));
         $result = $this->serializer->serialize($data, 'json');
         $this->assertEquals(json_encode($data), $result);
@@ -57,7 +52,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
 
     public function testEncode()
     {
-        $this->serializer->setEncoder('json', new JsonEncoder());
+        $this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
         $data = array('foo', array(5, 3));
         $result = $this->serializer->encode($data, 'json');
         $this->assertEquals(json_encode($data), $result);
@@ -65,18 +60,9 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
 
     public function testDecode()
     {
-        $this->serializer->setDecoder('json', new JsonEncoder());
+        $this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
         $data = array('foo', array(5, 3));
         $result = $this->serializer->decode(json_encode($data), 'json');
         $this->assertEquals($data, $result);
     }
-
-    /**
-     * @expectedException \UnexpectedValueException
-     */
-    public function testNormalizeNoMatchObject()
-    {
-        $this->serializer->addNormalizer($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer'));
-        $this->serializer->normalizeObject(new \stdClass, 'xml');
-    }
 }