/**
  * Transform a FacebookAds\Cursor object into a Collection.
  *
  * @param Cursor $response
  *
  * @return Collection
  */
 public function response(Cursor $response)
 {
     $data = new Collection();
     while ($response->current()) {
         $data->push($response->current()->getData());
         $response->next();
     }
     return $data;
 }
 public function testImplicitFetch()
 {
     // Test setters/getters
     $response = $this->createEmptyResponseMock();
     $cursor = new Cursor($response, $this->objectPrototype);
     $this->assertFalse(Cursor::getDefaultUseImplicitFetch());
     $this->assertFalse($cursor->getUseImplicitFetch());
     $cursor->setUseImplicitFetch(true);
     $this->assertTrue($cursor->getUseImplicitFetch());
     Cursor::setDefaultUseImplicitFetch(true);
     $response = $this->createEmptyResponseMock();
     $cursor = new Cursor($response, $this->objectPrototype);
     $this->assertTrue(Cursor::getDefaultUseImplicitFetch());
     $this->assertTrue($cursor->getUseImplicitFetch());
     // Test ordered iteration
     // f() lower interval * min repetition > upper interval
     // Min repetition > upper interval / lower interval -> f(x): x > 5 / 2 -> 3
     $response = $this->createResponseChainMock(3);
     $cursor = new Cursor($response, $this->objectPrototype);
     while ($cursor->valid()) {
         $cursor->next();
     }
     // Min upper boundary = upper interval + 1 = 5 + 1 = 6
     $this->assertGreaterThanOrEqual(6, $cursor->count());
     // Test rervese iteration
     // same f()
     $response = $this->createResponseChainMock(3);
     $cursor = new Cursor($response, $this->objectPrototype);
     $count = 0;
     while ($cursor->valid()) {
         $cursor->prev();
     }
     $this->assertGreaterThanOrEqual(6, $cursor->count());
     // Force the array out of boundaries
     $response = $this->createResponseChainMock(1);
     $cursor = new Cursor($response, $this->objectPrototype);
     $cursor->setUseImplicitFetch(false);
     $cursor->prev();
     // Restore static behaviour
     Cursor::setDefaultUseImplicitFetch(false);
 }