These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Hateoas\Tests\Representation; |
||
4 | |||
5 | use Hateoas\Representation\CollectionRepresentation; |
||
6 | use Hateoas\Representation\RouteAwareRepresentation; |
||
7 | |||
8 | class RouteAwareRepresentationTest extends RepresentationTestCase |
||
9 | { |
||
10 | View Code Duplication | public function testSerialize() |
|
11 | { |
||
12 | $collection = new RouteAwareRepresentation( |
||
13 | new CollectionRepresentation( |
||
14 | array( |
||
15 | 'Adrien', |
||
16 | 'William', |
||
17 | ), |
||
18 | 'authors', |
||
19 | 'users' |
||
20 | ), |
||
21 | '/authors', |
||
22 | array( |
||
23 | 'query' => 'willdurand/Hateoas', |
||
24 | ) |
||
25 | ); |
||
26 | |||
27 | $this |
||
28 | ->string($this->hateoas->serialize($collection, 'xml')) |
||
29 | ->isEqualTo(<<<XML |
||
30 | <?xml version="1.0" encoding="UTF-8"?> |
||
31 | <result> |
||
32 | <users rel="authors"> |
||
33 | <entry><![CDATA[Adrien]]></entry> |
||
34 | <entry><![CDATA[William]]></entry> |
||
35 | </users> |
||
36 | <link rel="self" href="/authors?query=willdurand%2FHateoas"/> |
||
37 | </result> |
||
38 | |||
39 | XML |
||
40 | ) |
||
41 | ->string($this->halHateoas->serialize($collection, 'xml')) |
||
42 | ->isEqualTo(<<<XML |
||
43 | <?xml version="1.0" encoding="UTF-8"?> |
||
44 | <result href="/authors?query=willdurand%2FHateoas"> |
||
45 | <resource rel="authors"><![CDATA[Adrien]]></resource> |
||
46 | <resource rel="authors"><![CDATA[William]]></resource> |
||
47 | </result> |
||
48 | |||
49 | XML |
||
50 | ); |
||
51 | |||
52 | $this |
||
53 | ->json($this->halHateoas->serialize($collection, 'json')) |
||
54 | ->isEqualTo(<<<JSON |
||
55 | { |
||
56 | "_links": { |
||
57 | "self": { |
||
58 | "href": "\/authors?query=willdurand%2FHateoas" |
||
59 | } |
||
60 | }, |
||
61 | "_embedded": { |
||
62 | "authors": [ |
||
63 | "Adrien", |
||
64 | "William" |
||
65 | ] |
||
66 | } |
||
67 | } |
||
68 | JSON |
||
69 | ); |
||
70 | } |
||
71 | |||
72 | View Code Duplication | public function testGenerateAbsoluteURIs() |
|
73 | { |
||
74 | $collection = new RouteAwareRepresentation( |
||
75 | new CollectionRepresentation( |
||
76 | array( |
||
77 | 'Adrien', |
||
78 | 'William', |
||
79 | ), |
||
80 | 'authors', |
||
81 | 'users' |
||
82 | ), |
||
83 | '/authors', |
||
84 | array( |
||
85 | 'query' => 'willdurand/Hateoas', |
||
86 | ), |
||
87 | true // absolute |
||
88 | ); |
||
89 | |||
90 | $this |
||
0 ignored issues
–
show
|
|||
91 | ->string($this->hateoas->serialize($collection, 'xml')) |
||
92 | ->isEqualTo(<<<XML |
||
93 | <?xml version="1.0" encoding="UTF-8"?> |
||
94 | <result> |
||
95 | <users rel="authors"> |
||
96 | <entry><![CDATA[Adrien]]></entry> |
||
97 | <entry><![CDATA[William]]></entry> |
||
98 | </users> |
||
99 | <link rel="self" href="http://example.com/authors?query=willdurand%2FHateoas"/> |
||
100 | </result> |
||
101 | |||
102 | XML |
||
103 | ) |
||
104 | ->string($this->halHateoas->serialize($collection, 'xml')) |
||
105 | ->isEqualTo(<<<XML |
||
106 | <?xml version="1.0" encoding="UTF-8"?> |
||
107 | <result href="http://example.com/authors?query=willdurand%2FHateoas"> |
||
108 | <resource rel="authors"><![CDATA[Adrien]]></resource> |
||
109 | <resource rel="authors"><![CDATA[William]]></resource> |
||
110 | </result> |
||
111 | |||
112 | XML |
||
113 | ); |
||
114 | |||
115 | $this |
||
116 | ->json($this->halHateoas->serialize($collection, 'json')) |
||
117 | ->isEqualTo(<<<JSON |
||
118 | { |
||
119 | "_links": { |
||
120 | "self": { |
||
121 | "href": "http:\/\/example.com\/authors?query=willdurand%2FHateoas" |
||
122 | } |
||
123 | }, |
||
124 | "_embedded": { |
||
125 | "authors": [ |
||
126 | "Adrien", |
||
127 | "William" |
||
128 | ] |
||
129 | } |
||
130 | } |
||
131 | JSON |
||
132 | ); |
||
133 | } |
||
134 | } |
||
135 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.