public function testGetters() { $objects = array(new AdAccount()); $cursor = new Cursor($objects, $this->response); $this->assertTrue($this->response === $cursor->getResponse()); $this->assertTrue($objects === $cursor->getObjects()); $this->assertEquals($this->after, $cursor->getAfter()); $this->assertEquals($this->before, $cursor->getBefore()); }
public function testExportability() { $response = $this->createResponseChainMock(1); $cursor = new Cursor($response, $this->objectPrototype); $array_copy = $cursor->getArrayCopy(); $this->assertTrue(is_array($array_copy)); $this->assertEquals($cursor->getArrayCopy(), $cursor->getObjects()); $this->assertEquals(count($array_copy), count($response->getContent()['data'])); foreach ($array_copy as $object) { if (!$object instanceof AbstractObject) { $this->fail("Wrong instance in array copy"); } } $cursor->fetchAfter(); $cursor->fetchBefore(); $index = $cursor->getIndexLeft(); // Test in-memory order while exporting foreach ($cursor->getArrayCopy(true) as $key => $object) { if ($key < $index) { $this->fail("Wrong order in sorted array copy"); } } }