You are here

public function XmlEncoderTest::testAttributes 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::testAttributes()

File

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

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'));
}