| @@ 281-306 (lines=26) @@ | ||
| 278 | ); |
|
| 279 | } |
|
| 280 | ||
| 281 | public function testGh236() |
|
| 282 | { |
|
| 283 | $data = new CollectionRepresentation([new Gh236Foo()]); |
|
| 284 | ||
| 285 | $hateoas = HateoasBuilder::buildHateoas(); |
|
| 286 | ||
| 287 | $this->assertSame( |
|
| 288 | <<<JSON |
|
| 289 | { |
|
| 290 | "_embedded": { |
|
| 291 | "items": [ |
|
| 292 | { |
|
| 293 | "a": { |
|
| 294 | "xxx": "yyy" |
|
| 295 | }, |
|
| 296 | "_embedded": { |
|
| 297 | "b_embed": { |
|
| 298 | "xxx": "zzz" |
|
| 299 | } |
|
| 300 | } |
|
| 301 | } |
|
| 302 | ] |
|
| 303 | } |
|
| 304 | } |
|
| 305 | JSON |
|
| 306 | , |
|
| 307 | $this->json( |
|
| 308 | $hateoas->serialize($data, 'json', SerializationContext::create()->enableMaxDepthChecks()) |
|
| 309 | ) |
|
| @@ 51-74 (lines=24) @@ | ||
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function testGh236() |
|
| 52 | { |
|
| 53 | $data = new CollectionRepresentation([new Gh236Foo()]); |
|
| 54 | ||
| 55 | $hateoas = HateoasBuilder::create() |
|
| 56 | ->setXmlSerializer(new XmlHalSerializer()) |
|
| 57 | ->build(); |
|
| 58 | ||
| 59 | $this->assertSame( |
|
| 60 | <<<XML |
|
| 61 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 62 | <collection> |
|
| 63 | <resource rel="items"> |
|
| 64 | <a> |
|
| 65 | <xxx><![CDATA[yyy]]></xxx> |
|
| 66 | </a> |
|
| 67 | <resource rel="b_embed"> |
|
| 68 | <xxx><![CDATA[zzz]]></xxx> |
|
| 69 | </resource> |
|
| 70 | </resource> |
|
| 71 | </collection> |
|
| 72 | ||
| 73 | XML |
|
| 74 | , |
|
| 75 | $hateoas->serialize($data, 'xml', SerializationContext::create()->enableMaxDepthChecks()) |
|
| 76 | ); |
|
| 77 | } |
|
| @@ 119-142 (lines=24) @@ | ||
| 116 | ); |
|
| 117 | } |
|
| 118 | ||
| 119 | public function testGh236() |
|
| 120 | { |
|
| 121 | $data = new CollectionRepresentation([new Gh236Foo()]); |
|
| 122 | ||
| 123 | $hateoas = HateoasBuilder::buildHateoas(); |
|
| 124 | ||
| 125 | $this->assertSame( |
|
| 126 | <<<XML |
|
| 127 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 128 | <collection> |
|
| 129 | <entry rel="items"> |
|
| 130 | <entry> |
|
| 131 | <a> |
|
| 132 | <xxx><![CDATA[yyy]]></xxx> |
|
| 133 | </a> |
|
| 134 | <entry rel="b_embed"> |
|
| 135 | <xxx><![CDATA[zzz]]></xxx> |
|
| 136 | </entry> |
|
| 137 | </entry> |
|
| 138 | </entry> |
|
| 139 | </collection> |
|
| 140 | ||
| 141 | XML |
|
| 142 | , |
|
| 143 | $hateoas->serialize($data, 'xml', SerializationContext::create()->enableMaxDepthChecks()) |
|
| 144 | ); |
|
| 145 | } |
|