Skip to content

Commit

Permalink
Remove references to Graph list from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SammyK committed May 8, 2015
1 parent 9504664 commit 1e7d07a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes
- Added methods to make pagination easier
- Added "deep" pagination support so that Graph edges embedded in a Graph node can be paginated over easily
- Beta support at `graph.beta.facebook.com`
- Added `getMetaData()` to `GraphList` to obtain all the metadata associated with a list of Graph nodes
- Added `getMetaData()` to `GraphEdge` to obtain all the metadata associated with a list of Graph nodes
- Full nested param support
- Many improvements to the Graph node subtypes
- New injectable interfaces
Expand Down
24 changes: 12 additions & 12 deletions src/Facebook/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,55 +430,55 @@ public function delete($endpoint, array $params = [], $accessToken = null, $eTag
/**
* Sends a request to Graph for the next page of results.
*
* @param GraphEdge $graphList The GraphEdge to paginate over.
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
*
* @return GraphEdge|null
*
* @throws FacebookSDKException
*/
public function next(GraphEdge $graphList)
public function next(GraphEdge $graphEdge)
{
return $this->getPaginationResults($graphList, 'next');
return $this->getPaginationResults($graphEdge, 'next');
}

/**
* Sends a request to Graph for the previous page of results.
*
* @param GraphEdge $graphList The GraphEdge to paginate over.
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
*
* @return GraphEdge|null
*
* @throws FacebookSDKException
*/
public function previous(GraphEdge $graphList)
public function previous(GraphEdge $graphEdge)
{
return $this->getPaginationResults($graphList, 'previous');
return $this->getPaginationResults($graphEdge, 'previous');
}

/**
* Sends a request to Graph for the next page of results.
*
* @param GraphEdge $graphList The GraphEdge to paginate over.
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
* @param string $direction The direction of the pagination: next|previous.
*
* @return GraphEdge|null
*
* @throws FacebookSDKException
*/
public function getPaginationResults(GraphEdge $graphList, $direction)
public function getPaginationResults(GraphEdge $graphEdge, $direction)
{
$paginationRequest = $graphList->getPaginationRequest($direction);
$paginationRequest = $graphEdge->getPaginationRequest($direction);
if (!$paginationRequest) {
return null;
}

$this->lastResponse = $this->client->sendRequest($paginationRequest);

// Keep the same GraphNode subclass
$subClassName = $graphList->getSubClassName();
$graphList = $this->lastResponse->getGraphList($subClassName, false);
$subClassName = $graphEdge->getSubClassName();
$graphEdge = $this->lastResponse->getGraphEdge($subClassName, false);

return count($graphList) > 0 ? $graphList : null;
return count($graphEdge) > 0 ? $graphEdge : null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/FacebookBatchResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public function testASuccessfulJsonBatchResponseWillBeDecoded()
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $decodedResponses[0]->getGraphNode());
// Paginated list of Graph objects.
$this->assertFalse($decodedResponses[1]->isError(), 'Did not expect Response to return an error for paginated list of Graph objects.');
$graphList = $decodedResponses[1]->getGraphList();
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphList[0]);
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphList[1]);
$graphEdge = $decodedResponses[1]->getGraphEdge();
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphEdge[0]);
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphEdge[1]);
}

public function testABatchResponseCanBeIteratedOver()
Expand Down
4 changes: 2 additions & 2 deletions tests/FacebookResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public function testASuccessfulJsonResponseWillBeDecodedToAGraphNode()
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphNode);
}

public function testASuccessfulJsonResponseWillBeDecodedToAGraphList()
public function testASuccessfulJsonResponseWillBeDecodedToAGraphEdge()
{
$graphResponseJson = '{"data":[{"id":"123","name":"Foo"},{"id":"1337","name":"Bar"}]}';
$response = new FacebookResponse($this->request, $graphResponseJson, 200);

$graphEdge = $response->getGraphList();
$graphEdge = $response->getGraphEdge();

$this->assertFalse($response->isError(), 'Did not expect Response to return an error.');
$this->assertInstanceOf('Facebook\GraphNodes\GraphNode', $graphEdge[0]);
Expand Down
4 changes: 2 additions & 2 deletions tests/FacebookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function testPaginationReturnsProperResponse()
$fb = new Facebook($config);

$request = new FacebookRequest($fb->getApp(), 'foo_token', 'GET');
$graphList = new GraphEdge(
$graphEdge = new GraphEdge(
$request,
[],
[
Expand All @@ -369,7 +369,7 @@ public function testPaginationReturnsProperResponse()
'\Facebook\GraphNodes\GraphUser'
);

$nextPage = $fb->next($graphList);
$nextPage = $fb->next($graphEdge);
$this->assertInstanceOf('Facebook\GraphNodes\GraphEdge', $nextPage);
$this->assertInstanceOf('Facebook\GraphNodes\GraphUser', $nextPage[0]);
$this->assertEquals('Foo', $nextPage[0]['name']);
Expand Down

0 comments on commit 1e7d07a

Please sign in to comment.