Conditions | 1 |
Paths | 1 |
Total Lines | 44 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | public function testSerialize() |
||
11 | { |
||
12 | $error = new VndErrorRepresentation( |
||
13 | 'Validation failed', |
||
14 | 42, |
||
15 | new Relation('help', 'http://.../', null, array('title' => 'Error Information')), |
||
16 | new Relation('describes', 'http://.../', null, array('title' => 'Error Description')) |
||
17 | ); |
||
18 | |||
19 | $this->assertSame( |
||
20 | <<<XML |
||
21 | <?xml version="1.0" encoding="UTF-8"?> |
||
22 | <resource logref="42"> |
||
23 | <message><![CDATA[Validation failed]]></message> |
||
24 | <link rel="help" href="http://.../" title="Error Information"/> |
||
25 | <link rel="describes" href="http://.../" title="Error Description"/> |
||
26 | </resource> |
||
27 | |||
28 | XML |
||
29 | , |
||
30 | $this->hateoas->serialize($error, 'xml') |
||
31 | ); |
||
32 | |||
33 | $this->assertSame( |
||
34 | <<<JSON |
||
35 | { |
||
36 | "message": "Validation failed", |
||
37 | "logref": 42, |
||
38 | "_links": { |
||
39 | "help": { |
||
40 | "href": "http:\/\/...\/", |
||
41 | "title": "Error Information" |
||
42 | }, |
||
43 | "describes": { |
||
44 | "href": "http:\/\/...\/", |
||
45 | "title": "Error Description" |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 | JSON |
||
50 | , |
||
51 | $this->json($this->halHateoas->serialize($error, 'json')) |
||
52 | ); |
||
53 | } |
||
54 | } |
||
55 |