public function testShouldReturnAnArrayWhenThereAreNoMorePages()
 {
     $mock = new MockHandler([new Response(200, ['X-Foo' => 'Bar'], json_encode(['something' => 'else']))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $groupsPageIterator = new MarketGroupsPagesIterator(json_decode(json_encode(['foo' => 'bar'])), $client);
     $iterator = iterator_to_array($groupsPageIterator->getAllPages());
     $this->assertInstanceOf(\Generator::class, $groupsPageIterator->getAllPages());
     $this->assertNotEmpty($groupsPageIterator);
 }
Esempio n. 2
0
 /**
  * Uses the Guzzel Pool to process Requests.
  *
  * Processes with a concurrency of 18, since Eve limits to 20.
  *
  * Uses a promise and will wait until finished.
  *
  * @param callback function - used for rejected responses. $reason and $index are injected.
  */
 public function fetchGroupsInfromation($rejectedCallbackFunction)
 {
     $pool = new Pool($this->client, $this->createdRequests, ['concurrency' => 18, 'fulfilled' => function ($response, $index) {
         $responseJson = json_decode($response->getBody()->getContents());
         $groupPagesIterator = new MarketGroupsPagesIterator($responseJson, $this->client);
         $this->acceptedResponses[$index] = iterator_to_array($groupPagesIterator->getAllPages());
     }, 'rejected' => function ($reason, $index) use(&$rejectedCallbackFunction) {
         call_user_func_array($rejectedCallbackFunction, array($reason, $index));
     }]);
     $promise = $pool->promise();
     $promise->wait();
 }