This repository was archived by the owner on Jan 13, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -235,4 +235,18 @@ public function getTotalCount()
235235
236236 return null ;
237237 }
238+
239+ /**
240+ * @{inherited}
241+ */
242+ public function map (\Closure $ callback )
243+ {
244+ return new static (
245+ $ this ->request ,
246+ array_map ($ callback , $ this ->items , array_keys ($ this ->items )),
247+ $ this ->metaData ,
248+ $ this ->parentEdgeEndpoint ,
249+ $ this ->subclassName
250+ );
251+ }
238252}
Original file line number Diff line number Diff line change 2626use Facebook \FacebookApp ;
2727use Facebook \FacebookRequest ;
2828use Facebook \GraphNodes \GraphEdge ;
29+ use Facebook \GraphNodes \GraphNode ;
2930
3031class GraphEdgeTest extends \PHPUnit_Framework_TestCase
3132{
@@ -96,4 +97,28 @@ public function testCanInstantiateNewPaginationRequest()
9697 $ this ->assertEquals ('/v1337/998899/photos?access_token=foo_token&after=foo_after_cursor&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&foo=bar&limit=25&pretty=0 ' , $ nextPage ->getUrl ());
9798 $ this ->assertEquals ('/v1337/998899/photos?access_token=foo_token&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&before=foo_before_cursor&foo=bar&limit=25&pretty=0 ' , $ prevPage ->getUrl ());
9899 }
100+
101+ public function testCanMapOverNodes ()
102+ {
103+ $ graphEdge = new GraphEdge (
104+ $ this ->request ,
105+ [new GraphNode (['name ' => 'dummy ' ])],
106+ ['paging ' => $ this ->pagination ],
107+ '/1234567890/likes '
108+ );
109+
110+ $ graphEdge = $ graphEdge ->map (function (GraphNode $ node ) {
111+ $ node ['name ' ] = str_replace ('dummy ' , 'foo ' , $ node ['name ' ]);
112+ return $ node ;
113+ });
114+
115+ $ graphEdgeToCompare = new GraphEdge (
116+ $ this ->request ,
117+ [new GraphNode (['name ' => 'foo ' ])],
118+ ['paging ' => $ this ->pagination ],
119+ '/1234567890/likes '
120+ );
121+
122+ $ this ->assertEquals ($ graphEdgeToCompare , $ graphEdge );
123+ }
99124}
You can’t perform that action at this time.
0 commit comments