public function XmlEncoderTest::testAttributes

File

drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php, line 62

Class

XmlEncoderTest

Namespace

Symfony\Component\Serializer\Tests\Encoder

Code

public function testAttributes() {
  $obj = new ScalarDummy();
  $obj->xmlFoo = array(
    'foo-bar' => array(
      '@id' => 1,
      '@name' => 'Bar',
    ),
    'Foo' => array(
      'Bar' => "Test",
      '@Type' => 'test',
    ),
    'föo_bär' => 'a',
    "Bar" => array(
      1,
      2,
      3,
    ),
    'a' => 'b',
  );
  $expected = '<?xml version="1.0"?>' . "\n" . '<response>' . '<foo-bar id="1" name="Bar"/>' . '<Foo Type="test"><Bar>Test</Bar></Foo>' . '<föo_bär>a</föo_bär>' . '<Bar>1</Bar>' . '<Bar>2</Bar>' . '<Bar>3</Bar>' . '<a>b</a>' . '</response>' . "\n";
  $this
    ->assertEquals($expected, $this->encoder
    ->encode($obj, 'xml'));
}