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 GraphObjectFactory($this->responseMock);
     $graphObject = $factory->makeGraphAlbum();
     $place = $graphObject->getPlace();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPage', $place);
 }
 public function testUserPropertiesWillGetCastAsGraphUserObjects()
 {
     $dataFromGraph = ['id' => '123', 'name' => 'Foo User', 'significant_other' => ['id' => '1337', 'name' => 'Bar User']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphObjectFactory($this->responseMock);
     $graphObject = $factory->makeGraphUser();
     $significantOther = $graphObject->getSignificantOther();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphUser', $significantOther);
 }
 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 GraphObjectFactory($this->responseMock);
     $graphObject = $factory->makeGraphPage();
     $location = $graphObject->getLocation();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphLocation', $location);
 }
 public function testDatesGetCastToDateTime()
 {
     $dataFromGraph = ['expires_at' => 123, 'issued_at' => 1337];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphObjectFactory($this->responseMock);
     $graphObject = $factory->makeGraphSessionInfo();
     $expires = $graphObject->getExpiresAt();
     $issuedAt = $graphObject->getIssuedAt();
     $this->assertInstanceOf('DateTime', $expires);
     $this->assertInstanceOf('DateTime', $issuedAt);
 }
 public function testACollectionWillBeCastRecursively()
 {
     $someUser = ['id' => '123', 'name' => 'Foo McBar'];
     $likesCollection = ['data' => [['id' => '1', 'name' => 'Sammy Kaye Powers', 'is_sexy' => true], ['id' => '2', 'name' => 'Yassine Guedidi', 'is_sexy' => true], ['id' => '3', 'name' => 'Fosco Marotto', 'is_sexy' => true], ['id' => '4', 'name' => 'Foo McUgly', 'is_sexy' => false]], 'paging' => ['next' => 'http://facebook/next_likes', 'previous' => 'http://facebook/prev_likes']];
     $commentsCollection = ['data' => [['id' => '42_1', 'from' => $someUser, 'message' => 'Foo comment.', 'created_time' => '2014-07-15T03:54:34+0000', 'likes' => $likesCollection], ['id' => '42_2', 'from' => $someUser, 'message' => 'Bar comment.', 'created_time' => '2014-07-15T04:11:24+0000', 'likes' => $likesCollection]], 'paging' => ['next' => 'http://facebook/next_comments', 'previous' => 'http://facebook/prev_comments']];
     $dataFromGraph = ['data' => [['id' => '1337_1', 'from' => $someUser, 'story' => 'Some great foo story.', 'likes' => $likesCollection, 'comments' => $commentsCollection], ['id' => '1337_2', 'from' => $someUser, 'to' => ['data' => [$someUser]], 'message' => 'Some great bar message.', 'likes' => $likesCollection, 'comments' => $commentsCollection]], 'paging' => ['next' => 'http://facebook/next', 'previous' => 'http://facebook/prev']];
     $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph);
     $factory = new GraphObjectFactory($this->responseMock);
     $graphObject = $factory->makeGraphList();
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphList', $graphObject);
     // Story
     $storyObject = $graphObject[0];
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphObject', $storyObject['from']);
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphList', $storyObject['likes']);
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphList', $storyObject['comments']);
     // Story Comments
     $storyComments = $storyObject['comments'];
     $firstStoryComment = $storyComments[0];
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphObject', $firstStoryComment['from']);
     // Message
     $messageObject = $graphObject[1];
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphList', $messageObject['to']);
     $toUsers = $messageObject['to'];
     $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphObject', $toUsers[0]);
 }