mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-28 19:13:15 +02:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
--TEST--
|
|
MongoDB\Driver\Cursor get_iterator handler does not yield multiple iterators (IteratorIterator)
|
|
--SKIPIF--
|
|
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM cannot detect the *wrapping* of a Cursor"); ?>
|
|
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
|
|
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
|
|
--FILE--
|
|
<?php
|
|
require_once __DIR__ . "/../utils/basic.inc";
|
|
|
|
$manager = new MongoDB\Driver\Manager(STANDALONE);
|
|
|
|
$bulkWrite = new MongoDB\Driver\BulkWrite;
|
|
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$bulkWrite->insert(array('_id' => $i));
|
|
}
|
|
|
|
$writeResult = $manager->executeBulkWrite(NS, $bulkWrite);
|
|
printf("Inserted: %d\n", $writeResult->getInsertedCount());
|
|
|
|
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()));
|
|
|
|
echo "\nFirst IteratorIterator wrapping:\n";
|
|
|
|
var_dump(new IteratorIterator($cursor));
|
|
|
|
echo "\nSecond IteratorIterator wrapping:\n";
|
|
|
|
try {
|
|
var_dump(new IteratorIterator($cursor));
|
|
} catch (MongoDB\Driver\Exception\LogicException $e) {
|
|
printf("LogicException: %s\n", $e->getMessage());
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECTF--
|
|
Inserted: 3
|
|
|
|
First IteratorIterator wrapping:
|
|
object(IteratorIterator)#%d (0) {
|
|
}
|
|
|
|
Second IteratorIterator wrapping:
|
|
LogicException: Cursors cannot yield multiple iterators
|
|
===DONE===
|