public function testExtract($query, $chunkSize, array $options = array(), array $expected)
{
$chunks = str_split($query, $chunkSize);
$count = count($chunks);
/**
* The array of extracted statements.
*
* @var array $statements
*/
$statements = array();
/**
* The `BufferedQuery` instance used for extraction.
*
* @var BufferedQuery $bq
*/
$bq = new BufferedQuery('', $options);
// Feeding chunks and extracting queries.
$i = 0;
while ($i < $count) {
if ($stmt = $bq->extract()) {
$statements[] = $stmt;
} else {
$bq->query .= $chunks[$i++];
}
}
// Feeding ended, extracting remaining queries.
while ($stmt = $bq->extract(true)) {
$statements[] = $stmt;
}
$this->assertEquals($expected, $statements);
}