|
26 | 26 | use Facebook\FacebookApp;
|
27 | 27 | use Facebook\FacebookRequest;
|
28 | 28 | use Facebook\GraphNodes\GraphEdge;
|
| 29 | +use Facebook\GraphNodes\GraphNode; |
29 | 30 |
|
30 | 31 | class GraphEdgeTest extends \PHPUnit_Framework_TestCase
|
31 | 32 | {
|
@@ -96,4 +97,34 @@ public function testCanInstantiateNewPaginationRequest()
|
96 | 97 | $this->assertEquals('/v1337/998899/photos?access_token=foo_token&after=foo_after_cursor&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&foo=bar&limit=25&pretty=0', $nextPage->getUrl());
|
97 | 98 | $this->assertEquals('/v1337/998899/photos?access_token=foo_token&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&before=foo_before_cursor&foo=bar&limit=25&pretty=0', $prevPage->getUrl());
|
98 | 99 | }
|
| 100 | + |
| 101 | + public function testCanMapOverNodes() |
| 102 | + { |
| 103 | + $graphEdge = new GraphEdge( |
| 104 | + $this->request, |
| 105 | + [ |
| 106 | + new GraphNode(['name' => 'dummy']), |
| 107 | + new GraphNode(['name' => 'dummy']), |
| 108 | + ], |
| 109 | + ['paging' => $this->pagination], |
| 110 | + '/1234567890/likes' |
| 111 | + ); |
| 112 | + |
| 113 | + $graphEdge = $graphEdge->map(function (GraphNode $node) { |
| 114 | + $node['name'] = str_replace('dummy', 'foo', $node['name']); |
| 115 | + return $node; |
| 116 | + }); |
| 117 | + |
| 118 | + $graphEdgeToCompare = new GraphEdge( |
| 119 | + $this->request, |
| 120 | + [ |
| 121 | + new GraphNode(['name' => 'foo']), |
| 122 | + new GraphNode(['name' => 'foo']) |
| 123 | + ], |
| 124 | + ['paging' => $this->pagination], |
| 125 | + '/1234567890/likes' |
| 126 | + ); |
| 127 | + |
| 128 | + $this->assertEquals($graphEdgeToCompare, $graphEdge); |
| 129 | + } |
99 | 130 | }
|
0 commit comments