public function testNextPageAsyncCaching() { $results = array(); $pageSize = 2; $options = array("page_size" => $pageSize); $statement = new SimpleStatement("SELECT * FROM {$this->tableNamePrefix}"); // Get first page $rows = $this->session->execute($statement, new ExecutionOptions($options)); $this->assertEquals($rows->count(), $pageSize); $values = self::convertRowsToArray($rows, "value"); // Get next page asynchronously (verify that it's a different page) $nextRowsAsync = $rows->nextPageAsync()->get(); $this->assertEquals($nextRowsAsync->count(), $pageSize); $nextValuesAsync = self::convertRowsToArray($nextRowsAsync, "value"); $this->assertNotEquals($values, $nextValuesAsync); // Get next page asynchronously again (verify that it's the same) $nextRowsAgainAsync = $rows->nextPageAsync()->get(); $this->assertEquals($nextRowsAgainAsync->count(), $pageSize); $nextValuesAgainAsync = self::convertRowsToArray($nextRowsAgainAsync, "value"); $this->assertEquals($nextValuesAsync, $nextValuesAgainAsync); // Get the next page again synchonously (verify that it's the same) $nextRows = $rows->nextPage(); $nextValues = self::convertRowsToArray($nextRows, "value"); $this->assertEquals($nextRows->count(), $pageSize); $this->assertEquals($nextValuesAsync, $nextValues); // Get the next page's page asynchronously (verify that it's a different page) $lastRowsAsync = $nextRowsAsync->nextPageAsync()->get(); $this->assertEquals($lastRowsAsync->count(), $pageSize); $lastValuesAsync = self::convertRowsToArray($lastRowsAsync, "value"); $this->assertNotEquals($nextValuesAsync, $lastValuesAsync); }