@@ 177-214 (lines=38) @@ | ||
174 | $this->assertNotInstanceOf(MyFooGraphNode::class, $unknownObject); |
|
175 | } |
|
176 | ||
177 | public function testAListFromGraphWillBeCastAsAGraphEdge() |
|
178 | { |
|
179 | $data = json_encode([ |
|
180 | 'data' => [ |
|
181 | [ |
|
182 | 'id' => '123', |
|
183 | 'name' => 'Foo McBar', |
|
184 | 'link' => 'http://facebook/foo', |
|
185 | ], |
|
186 | [ |
|
187 | 'id' => '1337', |
|
188 | 'name' => 'Bar McBaz', |
|
189 | 'link' => 'http://facebook/bar', |
|
190 | ], |
|
191 | ], |
|
192 | 'paging' => [ |
|
193 | 'next' => 'http://facebook/next', |
|
194 | 'previous' => 'http://facebook/prev', |
|
195 | ], |
|
196 | ]); |
|
197 | $res = new Response($this->request, $data); |
|
198 | ||
199 | $factory = new GraphNodeFactory($res); |
|
200 | $graphEdge = $factory->makeGraphEdge(); |
|
201 | $graphData = $graphEdge->asArray(); |
|
202 | ||
203 | $this->assertInstanceOf(GraphEdge::class, $graphEdge); |
|
204 | $this->assertEquals([ |
|
205 | 'id' => '123', |
|
206 | 'name' => 'Foo McBar', |
|
207 | 'link' => 'http://facebook/foo', |
|
208 | ], $graphData[0]); |
|
209 | $this->assertEquals([ |
|
210 | 'id' => '1337', |
|
211 | 'name' => 'Bar McBaz', |
|
212 | 'link' => 'http://facebook/bar', |
|
213 | ], $graphData[1]); |
|
214 | } |
|
215 | ||
216 | public function testAGraphNodeWillBeCastAsAGraphNode() |
|
217 | { |
@@ 78-115 (lines=38) @@ | ||
75 | ], $graphData); |
|
76 | } |
|
77 | ||
78 | public function testAListFromGraphWillBeCastAsAGraphEdge() |
|
79 | { |
|
80 | $data = json_encode([ |
|
81 | 'data' => [ |
|
82 | [ |
|
83 | 'id' => '123', |
|
84 | 'name' => 'Foo McBar', |
|
85 | 'link' => 'http://facebook/foo', |
|
86 | ], |
|
87 | [ |
|
88 | 'id' => '1337', |
|
89 | 'name' => 'Bar McBaz', |
|
90 | 'link' => 'http://facebook/bar', |
|
91 | ], |
|
92 | ], |
|
93 | 'paging' => [ |
|
94 | 'next' => 'http://facebook/next', |
|
95 | 'previous' => 'http://facebook/prev', |
|
96 | ], |
|
97 | ]); |
|
98 | $res = new Response($this->request, $data); |
|
99 | ||
100 | $factory = new GraphObjectFactory($res); |
|
101 | $graphList = $factory->makeGraphList(); |
|
102 | $graphData = $graphList->asArray(); |
|
103 | ||
104 | $this->assertInstanceOf(GraphList::class, $graphList); |
|
105 | $this->assertEquals([ |
|
106 | 'id' => '123', |
|
107 | 'name' => 'Foo McBar', |
|
108 | 'link' => 'http://facebook/foo', |
|
109 | ], $graphData[0]); |
|
110 | $this->assertEquals([ |
|
111 | 'id' => '1337', |
|
112 | 'name' => 'Bar McBaz', |
|
113 | 'link' => 'http://facebook/bar', |
|
114 | ], $graphData[1]); |
|
115 | } |
|
116 | } |
|
117 |