You are here

public function XmlEncoderTest::testEncodeSerializerXmlRootNodeNameOption in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Tests/Encoder/XmlEncoderTest.php \Symfony\Component\Serializer\Tests\Encoder\XmlEncoderTest::testEncodeSerializerXmlRootNodeNameOption()

File

vendor/symfony/serializer/Tests/Encoder/XmlEncoderTest.php, line 234

Class

XmlEncoderTest

Namespace

Symfony\Component\Serializer\Tests\Encoder

Code

public function testEncodeSerializerXmlRootNodeNameOption() {
  $options = array(
    'xml_root_node_name' => 'test',
  );
  $this->encoder = new XmlEncoder();
  $serializer = new Serializer(array(), array(
    'xml' => new XmlEncoder(),
  ));
  $this->encoder
    ->setSerializer($serializer);
  $array = array(
    'person' => array(
      '@gender' => 'M',
      '#' => 'Peter',
    ),
  );
  $expected = '<?xml version="1.0"?>' . "\n" . '<test><person gender="M">Peter</person></test>' . "\n";
  $this
    ->assertEquals($expected, $serializer
    ->serialize($array, 'xml', $options));
}