@@ -8,40 +8,44 @@ MongoDB\Driver\Manager::selectServer() select a server from SDAM based on ReadPr
88<?php
99require_once __DIR__ . "/../utils/basic.inc " ;
1010
11- $ rp = new MongoDB \Driver \ReadPreference (MongoDB \Driver \ReadPreference::RP_PRIMARY );
1211$ manager = create_test_manager ();
12+
13+ $ rp = new MongoDB \Driver \ReadPreference ('primary ' );
1314$ server = $ manager ->selectServer ($ rp );
14- $ rp2 = new MongoDB \Driver \ReadPreference (MongoDB \Driver \ReadPreference::RP_PRIMARY );
15+
16+ $ rp2 = new MongoDB \Driver \ReadPreference ('primary ' );
1517$ server2 = $ manager ->selectServer ($ rp2 );
1618
1719// load fixtures for test
1820$ bulk = new \MongoDB \Driver \BulkWrite ();
19- $ bulk ->insert (array ( '_id ' => 1 , 'x ' => 2 , 'y ' => 3 ) );
20- $ bulk ->insert (array ( '_id ' => 2 , 'x ' => 3 , 'y ' => 4 ) );
21- $ bulk ->insert (array ( '_id ' => 3 , 'x ' => 4 , 'y ' => 5 ) );
21+ $ bulk ->insert ([ '_id ' => 1 , 'x ' => 2 , 'y ' => 3 ] );
22+ $ bulk ->insert ([ '_id ' => 2 , 'x ' => 3 , 'y ' => 4 ] );
23+ $ bulk ->insert ([ '_id ' => 3 , 'x ' => 4 , 'y ' => 5 ] );
2224$ server ->executeBulkWrite (NS , $ bulk );
2325
24- $ query = new MongoDB \Driver \Query (array ( 'x ' => 3 ), array ( 'projection ' => array ( 'y ' => 1 )) );
26+ $ query = new MongoDB \Driver \Query ([ 'x ' => 3 ], [ 'projection ' => [ 'y ' => 1 ]] );
2527$ cursor = $ server ->executeQuery (NS , $ query );
2628
2729var_dump ($ cursor instanceof MongoDB \Driver \Cursor);
2830var_dump ($ server == $ cursor ->getServer ());
2931var_dump (iterator_to_array ($ cursor ));
3032
31- $ query = new MongoDB \Driver \Query (array ( 'x ' => 3 ), array ( 'projection ' => array ( 'y ' => 1 )) );
33+ $ query = new MongoDB \Driver \Query ([ 'x ' => 3 ], [ 'projection ' => [ 'y ' => 1 ]] );
3234$ cursor = $ server2 ->executeQuery (NS , $ query );
3335
3436var_dump ($ cursor instanceof MongoDB \Driver \Cursor);
3537var_dump ($ server2 == $ cursor ->getServer ());
3638var_dump (iterator_to_array ($ cursor ));
3739
3840$ bulk = new \MongoDB \Driver \BulkWrite ();
39- $ bulk ->insert (array ('_id ' => 1 , 'x ' => 2 , 'y ' => 3 ));
40- $ bulk ->insert (array ('_id ' => 2 , 'x ' => 3 , 'y ' => 4 ));
41- $ bulk ->insert (array ('_id ' => 3 , 'x ' => 4 , 'y ' => 5 ));
41+ $ bulk ->insert (['_id ' => 1 , 'x ' => 2 , 'y ' => 3 ]);
42+ $ bulk ->insert (['_id ' => 2 , 'x ' => 3 , 'y ' => 4 ]);
43+ $ bulk ->insert (['_id ' => 3 , 'x ' => 4 , 'y ' => 5 ]);
44+
4245throws (function () use ($ server2 , $ bulk ) {
4346 $ server2 ->executeBulkWrite (NS , $ bulk );
4447}, "MongoDB\Driver\Exception\BulkWriteException " );
48+
4549?>
4650===DONE===
4751<?php exit (0 ); ?>
0 commit comments