예제 #1
0
 public function testVenueGetsCastAsGraphLocation()
 {
     $dataFromGraph = ['venue' => ['id' => '1337']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphNode = $factory->makeGraphGroup();
     $venue = $graphNode->getVenue();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphLocation', $venue);
 }
예제 #2
0
 public function testPlacePropertyWillGetCastAsGraphPageObject()
 {
     $dataFromGraph = ['id' => '123', 'name' => 'Foo Album', 'place' => ['id' => '1', 'name' => 'For Bar Place']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphNode = $factory->makeGraphAlbum();
     $place = $graphNode->getPlace();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPage', $place);
 }
예제 #3
0
 public function testLocationPropertyWillGetCastAsGraphLocationObject()
 {
     $dataFromGraph = ['id' => '123', 'name' => 'Foo Page', 'location' => ['city' => 'Washington', 'country' => 'United States', 'latitude' => 38.881634205431, 'longitude' => -77.029121075722, 'state' => 'DC']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphNode = $factory->makeGraphPage();
     $location = $graphNode->getLocation();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphLocation', $location);
 }
 public function testParentGroupGetsCastAsGraphGroup()
 {
     $dataFromGraph = ['parent_group' => ['id' => '1337']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphObject = $factory->makeGraphEvent();
     $parentGroup = $graphObject->getParentGroup();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphGroup', $parentGroup);
 }
예제 #5
0
 public function testDatesGetCastToDateTime()
 {
     $dataFromGraph = ['expires_at' => 123, 'issued_at' => 1337];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphNode = $factory->makeGraphSessionInfo();
     $expires = $graphNode->getExpiresAt();
     $issuedAt = $graphNode->getIssuedAt();
     $this->assertInstanceOf('DateTime', $expires);
     $this->assertInstanceOf('DateTime', $issuedAt);
 }
예제 #6
0
 public function testPicturePropertiesWillGetCastAsGraphPictureObjects()
 {
     $dataFromGraph = ['id' => '123', 'name' => 'Foo User', 'picture' => ['is_silhouette' => true, 'url' => 'http://foo.bar', 'width' => 200, 'height' => 200]];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphNodeFactory($this->responseMock);
     $graphNode = $factory->makeGraphUser();
     $Picture = $graphNode->getPicture();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPicture', $Picture);
     $this->assertTrue($Picture->isSilhouette());
     $this->assertEquals(200, $Picture->getWidth());
     $this->assertEquals(200, $Picture->getHeight());
     $this->assertEquals('http://foo.bar', $Picture->getUrl());
 }
예제 #7
0
 /**
  * Instantiate a new GraphEdge from response.
  *
  * @param string|null $subclassName The GraphNode subclass to cast list items to.
  * @param boolean     $auto_prefix  Toggle to auto-prefix the subclass name.
  *
  * @return \Facebook\GraphNodes\GraphEdge
  *
  * @throws FacebookSDKException
  */
 public function getGraphEdge($subclassName = null, $auto_prefix = true)
 {
     $factory = new GraphNodeFactory($this);
     return $factory->makeGraphEdge($subclassName, $auto_prefix);
 }
예제 #8
0
 public function testAGraphEdgeWillGenerateTheProperParentGraphEdges()
 {
     $likesList = ['data' => [['id' => '1', 'name' => 'Sammy Kaye Powers']], 'paging' => ['cursors' => ['after' => 'like_after_cursor', 'before' => 'like_before_cursor']]];
     $photosList = ['data' => [['id' => '777', 'name' => 'Foo Photo', 'likes' => $likesList]], 'paging' => ['cursors' => ['after' => 'photo_after_cursor', 'before' => 'photo_before_cursor']]];
     $data = json_encode(['data' => [['id' => '111', 'name' => 'Foo McBar', 'likes' => $likesList, 'photos' => $photosList], ['id' => '222', 'name' => 'Bar McBaz', 'likes' => $likesList, 'photos' => $photosList]], 'paging' => ['next' => 'http://facebook/next', 'previous' => 'http://facebook/prev']]);
     $res = new FacebookResponse($this->request, $data);
     $factory = new GraphNodeFactory($res);
     $graphEdge = $factory->makeGraphEdge();
     $topGraphEdge = $graphEdge->getParentGraphEdge();
     $childGraphEdgeOne = $graphEdge[0]['likes']->getParentGraphEdge();
     $childGraphEdgeTwo = $graphEdge[1]['likes']->getParentGraphEdge();
     $childGraphEdgeThree = $graphEdge[1]['photos']->getParentGraphEdge();
     $childGraphEdgeFour = $graphEdge[1]['photos'][0]['likes']->getParentGraphEdge();
     $this->assertNull($topGraphEdge);
     $this->assertEquals('/111/likes', $childGraphEdgeOne);
     $this->assertEquals('/222/likes', $childGraphEdgeTwo);
     $this->assertEquals('/222/photos', $childGraphEdgeThree);
     $this->assertEquals('/777/likes', $childGraphEdgeFour);
 }