| @@ 18-48 (lines=31) @@ | ||
| 15 | ||
| 16 | class XmlSerializerTest extends TestCase |
|
| 17 | { |
|
| 18 | public function testSerializeLinks() |
|
| 19 | { |
|
| 20 | $contextProphecy = $this->prophesize('JMS\Serializer\SerializationContext'); |
|
| 21 | ||
| 22 | $xmlSerializer = new XmlSerializer(); |
|
| 23 | $xmlSerializationVisitor = $this->createXmlSerializationVisitor(); |
|
| 24 | ||
| 25 | $links = array( |
|
| 26 | new Link('self', '/users/42'), |
|
| 27 | new Link('foo', '/bar', array('type' => 'magic')), |
|
| 28 | ); |
|
| 29 | ||
| 30 | $xmlSerializer->serializeLinks( |
|
| 31 | $links, |
|
| 32 | $xmlSerializationVisitor, |
|
| 33 | $contextProphecy->reveal() |
|
| 34 | ); |
|
| 35 | ||
| 36 | $this->assertSame( |
|
| 37 | <<<XML |
|
| 38 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 39 | <root> |
|
| 40 | <link rel="self" href="/users/42"/> |
|
| 41 | <link rel="foo" href="/bar" type="magic"/> |
|
| 42 | </root> |
|
| 43 | ||
| 44 | XML |
|
| 45 | , |
|
| 46 | $xmlSerializationVisitor->getResult() |
|
| 47 | ); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testSerializeEmbeddeds() |
|
| 51 | { |
|
| @@ 50-80 (lines=31) @@ | ||
| 47 | ); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testSerializeEmbeddeds() |
|
| 51 | { |
|
| 52 | $contextProphecy = $this->prophesize('JMS\Serializer\SerializationContext'); |
|
| 53 | ||
| 54 | $embeddeds = array( |
|
| 55 | new Embedded('friend', array('name' => 'John'), 'person'), |
|
| 56 | ); |
|
| 57 | ||
| 58 | $xmlSerializationVisitor = $this->createXmlSerializationVisitor(); |
|
| 59 | ||
| 60 | $xmlSerializer = new XmlSerializer(); |
|
| 61 | $xmlSerializer->serializeEmbeddeds( |
|
| 62 | $embeddeds, |
|
| 63 | $xmlSerializationVisitor, |
|
| 64 | $contextProphecy->reveal() |
|
| 65 | ); |
|
| 66 | ||
| 67 | $this->assertSame( |
|
| 68 | <<<XML |
|
| 69 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 70 | <root> |
|
| 71 | <person rel="friend"> |
|
| 72 | <entry/> |
|
| 73 | </person> |
|
| 74 | </root> |
|
| 75 | ||
| 76 | XML |
|
| 77 | , |
|
| 78 | $xmlSerializationVisitor->getResult() |
|
| 79 | ); |
|
| 80 | } |
|
| 81 | ||
| 82 | public function testSerializeAdrienBrault() |
|
| 83 | { |
|