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