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