/** * Instantiate a new GraphNode from response. * * @param string|null $subclassName The GraphNode subclass to cast to. * * @return \Facebook\GraphNodes\GraphNode * * @throws FacebookSDKException */ public function getGraphNode($subclassName = null) { $factory = new GraphNodeFactory($this); return $factory->makeGraphNode($subclassName); }
public function testAGraphNodeWithARootDataKeyWillBeCastAsAGraphNode() { $data = json_encode(['data' => ['id' => '123', 'name' => 'Foo McBar', 'link' => 'http://facebook/foo']]); $res = new FacebookResponse($this->request, $data); $factory = new GraphNodeFactory($res); $graphNode = $factory->makeGraphNode(); $graphData = $graphNode->asArray(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphNode', $graphNode); $this->assertEquals(['id' => '123', 'name' => 'Foo McBar', 'link' => 'http://facebook/foo'], $graphData); }