@@ -82,6 +82,22 @@ public function testFetchesTickets()
82
82
$ strategy = new CbpStrategy ('tickets ' , ['page[size] ' => 2 ]);
83
83
$ iterator = new PaginationIterator ($ mockTickets , $ strategy , 'findAll ' );
84
84
85
+ $ tickets = $ this ->iterator_to_array ($ iterator );
86
+
87
+ $ this ->assertEquals ([['id ' => 1 ], ['id ' => 2 ], ['id ' => 3 ], ['id ' => 4 ]], $ tickets );
88
+ $ this ->assertEquals ($ mockTickets ->response , $ iterator ->latestResponse ());
89
+ }
90
+
91
+ public function testFetchesTicketsIteratorToArray ()
92
+ {
93
+ $ this ->markTestSkipped ("Doesn't work unless you store all pages in the iterator " );
94
+ $ mockTickets = new MockResource ('tickets ' , [
95
+ [['id ' => 1 ], ['id ' => 2 ]],
96
+ [['id ' => 3 ], ['id ' => 4 ]]
97
+ ]);
98
+ $ strategy = new CbpStrategy ('tickets ' , ['page[size] ' => 2 ]);
99
+ $ iterator = new PaginationIterator ($ mockTickets , $ strategy , 'findAll ' );
100
+
85
101
$ tickets = iterator_to_array ($ iterator );
86
102
87
103
$ this ->assertEquals ([['id ' => 1 ], ['id ' => 2 ], ['id ' => 3 ], ['id ' => 4 ]], $ tickets );
@@ -97,7 +113,7 @@ public function testFetchesUsers()
97
113
$ strategy = new CbpStrategy ('users ' , ['page[size] ' => 2 ]);
98
114
$ iterator = new PaginationIterator ($ mockUsers , $ strategy , 'findAll ' );
99
115
100
- $ users = iterator_to_array ($ iterator );
116
+ $ users = $ this -> iterator_to_array ($ iterator );
101
117
102
118
$ this ->assertEquals ([
103
119
['id ' => 1 , 'name ' => 'User 1 ' ],
@@ -116,7 +132,7 @@ public function testFetchesCbpWithParams()
116
132
$ strategy = new CbpStrategy ('tickets ' , ['page[size] ' => 2 , 'any ' => 'param ' ]);
117
133
$ iterator = new PaginationIterator ($ mockTickets , $ strategy , 'findAll ' );
118
134
119
- $ tickets = iterator_to_array ($ iterator );
135
+ $ tickets = $ this -> iterator_to_array ($ iterator );
120
136
121
137
$ this ->assertEquals ([['id ' => 1 ], ['id ' => 2 ], ['id ' => 3 ], ['id ' => 4 ]], $ tickets );
122
138
$ this ->assertEquals ([
@@ -135,7 +151,7 @@ public function testFetchesSinglePageWithParams()
135
151
$ strategy = new SinglePageStrategy ($ resultsKey , $ userParams );
136
152
$ iterator = new PaginationIterator ($ mockResults , $ strategy , 'findAll ' );
137
153
138
- $ resources = iterator_to_array ($ iterator );
154
+ $ resources = $ this -> iterator_to_array ($ iterator );
139
155
140
156
$ this ->assertEquals ([
141
157
['id ' => 1 , 'name ' => 'Resource 1 ' ],
@@ -153,7 +169,7 @@ public function testCustomMethod()
153
169
$ strategy = new SinglePageStrategy ($ resultsKey , $ userParams );
154
170
$ iterator = new PaginationIterator ($ mockResults , $ strategy , 'findDifferent ' );
155
171
156
- $ resources = iterator_to_array ($ iterator );
172
+ $ resources = $ this -> iterator_to_array ($ iterator );
157
173
158
174
$ this ->assertEquals ([
159
175
['id ' => 1 , 'name ' => 'Resource 1 ' ],
0 commit comments