Chris@0: serializer = $this->container->get('serializer'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Confirms that modules can register normalizers and encoders. Chris@0: */ Chris@0: public function testSerializerComponentRegistration() { Chris@0: $object = new \stdClass(); Chris@0: $format = 'serialization_test'; Chris@0: $expected = 'Normalized by SerializationTestNormalizer, Encoded by SerializationTestEncoder'; Chris@0: Chris@0: // Ensure the serialization invokes the expected normalizer and encoder. Chris@0: $this->assertIdentical($this->serializer->serialize($object, $format), $expected); Chris@0: Chris@0: // Ensure the serialization fails for an unsupported format. Chris@0: try { Chris@0: $this->serializer->serialize($object, 'unsupported_format'); Chris@0: $this->fail('The serializer was expected to throw an exception for an unsupported format, but did not.'); Chris@0: } Chris@0: catch (UnexpectedValueException $e) { Chris@0: $this->pass('The serializer threw an exception for an unsupported format.'); Chris@0: } Chris@0: } Chris@0: Chris@0: }