Skip to content

Commit 4de6bc6

Browse files
committed
Use new cursor ID logic in tests where possible
1 parent 0693223 commit 4de6bc6

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

tests/cursorid/cursorid-002.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $bulk->insert(['_id' => 3]);
2121
$server->executeBulkWrite(NS, $bulk);
2222

2323
$cursor = $server->executeQuery(NS, new MongoDB\Driver\Query([], ['batchSize' => 2]));
24-
$cursorId = $cursor->getId();
24+
$cursorId = $cursor->getId(true);
2525

2626
$command = new MongoDB\Driver\Command([
2727
'killCursors' => COLLECTION_NAME,
@@ -32,13 +32,12 @@ $command = new MongoDB\Driver\Command([
3232
* unserializing the result document requires a 64-bit platform. */
3333
$result = $server->executeCommand(DATABASE_NAME, $command)->toArray()[0];
3434
printf("Killed %d cursor(s)\n", count($result->cursorsKilled));
35-
printf("Killed expected cursor: %s\n", (string) $cursorId === (string) $result->cursorsKilled[0] ? 'yes' : 'no');
35+
printf("Killed expected cursor: %s\n", $cursorId == $result->cursorsKilled[0] ? 'yes' : 'no');
3636

3737
?>
3838
===DONE===
3939
<?php exit(0); ?>
4040
--EXPECTF--
41-
Deprecated: MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead. in %s
4241
Killed 1 cursor(s)
4342
Killed expected cursor: yes
4443
===DONE===

tests/functional/cursorid-001.phpt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,17 @@ $query = new MongoDB\Driver\Query(array(), array(
2020

2121
$cursor = $manager->executeQuery(NS, $query);
2222

23-
$cursorid = $cursor->getId();
24-
$s1 = (string)$cursorid;
25-
var_dump(
26-
$cursorid,
27-
$s1
28-
);
29-
var_dump($s1 > 0);
23+
$cursorid = $cursor->getId(true);
24+
var_dump($cursorid);
25+
var_dump($cursorid != 0);
3026

3127
?>
3228
===DONE===
3329
<?php exit(0); ?>
3430
--EXPECTF--
35-
Deprecated: MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead. in %s
36-
object(MongoDB\Driver\CursorId)#%d (%d) {
37-
["id"]=>
38-
%rint\(\d+\)|string\(\d+\) "\d+"%r
31+
object(MongoDB\BSON\Int64)#%d (%d) {
32+
["integer"]=>
33+
string(%d) "%d"
3934
}
40-
string(%d) "%d"
4135
bool(true)
4236
===DONE===

0 commit comments

Comments
 (0)