/** * @dataProvider provideShortcodes */ public function testSerializer(SerializerInterface $serializer, $text, ShortcodeInterface $shortcode) { $serialized = $serializer->serialize($shortcode); $this->assertSame($text, $serialized); $s = $serializer->unserialize($text); $this->assertSame($shortcode->getName(), $s->getName()); $this->assertSame($shortcode->getParameters(), $s->getParameters()); $this->assertSame($shortcode->getContent(), $s->getContent()); }
public function unserialize($text, $format) { switch ($format) { case 'text': return $this->textSerializer->unserialize($text); case 'json': return $this->jsonSerializer->unserialize($text); case 'yaml': return $this->yamlSerializer->unserialize($text); case 'xml': return $this->xmlSerializer->unserialize($text); default: throw new \InvalidArgumentException(sprintf('Invalid unserialization format %s!', $format)); } }
/** * @dataProvider provideExceptions */ public function testSerializerExceptions(SerializerInterface $serializer, $value, $exceptionClass) { $this->setExpectedException($exceptionClass); $serializer->unserialize($value); }