11<?php
22
3+ use MongoDB \Driver \BulkWrite ;
34use MongoDB \Driver \Command ;
45use MongoDB \Driver \Manager ;
56use MongoDB \Driver \ReadPreference ;
67use MongoDB \Driver \Server ;
8+ use MongoDB \Driver \WriteConcern ;
9+ use MongoDB \Driver \WriteConcernError ;
10+ use MongoDB \Driver \WriteError ;
11+ use MongoDB \Driver \WriteResult ;
712use MongoDB \Driver \Exception \ConnectionException ;
813use MongoDB \Driver \Exception \RuntimeException ;
914
@@ -53,7 +58,7 @@ function drop_collection($uri, $databaseName, $collectionName)
5358 $ server ->executeCommand (
5459 $ databaseName ,
5560 $ command ,
56- [ 'writeConcern ' => new \ MongoDB \ Driver \ WriteConcern ( \ MongoDB \ Driver \ WriteConcern::MAJORITY ) ]
61+ ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY ) ]
5762 );
5863 } catch (RuntimeException $ e ) {
5964 if ($ e ->getMessage () !== 'ns not found ' ) {
@@ -162,11 +167,11 @@ function get_server_storage_engine($uri)
162167/**
163168 * Helper to return the version of a specific server.
164169 *
165- * @param MongoDB\Driver\ Server $server
170+ * @param Server $server
166171 * @return string
167172 * @throws RuntimeException
168173 */
169- function get_server_version_from_server (MongoDB \ Driver \ Server $ server )
174+ function get_server_version_from_server (Server $ server )
170175{
171176 $ command = new Command (['buildInfo ' => 1 ]);
172177 $ cursor = $ server ->executeCommand ('admin ' , $ command );
@@ -432,15 +437,15 @@ function SLOW() {
432437 }
433438}
434439
435- function loadFixtures (\ MongoDB \ Driver \ Manager $ manager , $ dbname = DATABASE_NAME , $ collname = COLLECTION_NAME , $ filename = null )
440+ function loadFixtures (Manager $ manager , $ dbname = DATABASE_NAME , $ collname = COLLECTION_NAME , $ filename = null )
436441{
437442 if (!$ filename ) {
438443 $ filename = "compress.zlib:// " . __DIR__ . "/ " . "PHONGO-FIXTURES.json.gz " ;
439444 }
440445
441- $ bulk = new MongoDB \ Driver \ BulkWrite (['ordered ' => false ]);
446+ $ bulk = new BulkWrite (['ordered ' => false ]);
442447
443- $ server = $ manager ->selectServer (new MongoDB \ Driver \ ReadPreference (MongoDB \ Driver \ ReadPreference::RP_PRIMARY ));
448+ $ server = $ manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
444449
445450 $ data = file_get_contents ($ filename );
446451 $ array = json_decode ($ data );
@@ -573,12 +578,13 @@ function throws($function, $exceptionname, $infunction = null) {
573578 }
574579 echo "FAILED: Expected $ exceptionname thrown, but no exception thrown! \n" ;
575580}
576- function printServer (MongoDB \Driver \Server $ server )
581+
582+ function printServer (Server $ server )
577583{
578584 printf ("server: %s:%d \n" , $ server ->getHost (), $ server ->getPort ());
579585}
580586
581- function printWriteResult (MongoDB \ Driver \ WriteResult $ result , $ details = true )
587+ function printWriteResult (WriteResult $ result , $ details = true )
582588{
583589 printServer ($ result ->getServer ());
584590
@@ -601,7 +607,7 @@ function printWriteResult(MongoDB\Driver\WriteResult $result, $details = true)
601607 }
602608}
603609
604- function printWriteConcernError (MongoDB \ Driver \ WriteConcernError $ error = null , $ details )
610+ function printWriteConcernError (WriteConcernError $ error = null , $ details )
605611{
606612 if ($ error ) {
607613 /* This stuff is generated by the server, no need for us to test it */
@@ -617,7 +623,7 @@ function printWriteConcernError(MongoDB\Driver\WriteConcernError $error = null,
617623 }
618624}
619625
620- function printWriteError (MongoDB \ Driver \ WriteError $ error )
626+ function printWriteError (WriteError $ error )
621627{
622628 var_dump ($ error );
623629 printf ("writeError[%d].message: %s \n" , $ error ->getIndex (), $ error ->getMessage ());
@@ -646,7 +652,7 @@ function def($arr) {
646652 }
647653}
648654
649- function configureFailPoint (MongoDB \ Driver \ Manager $ manager , $ failPoint , $ mode , array $ data = [])
655+ function configureFailPoint (Manager $ manager , $ failPoint , $ mode , array $ data = [])
650656{
651657 $ doc = array (
652658 'configureFailPoint ' => $ failPoint ,
@@ -656,11 +662,11 @@ function configureFailPoint(MongoDB\Driver\Manager $manager, $failPoint, $mode,
656662 $ doc ['data ' ] = $ data ;
657663 }
658664
659- $ cmd = new MongoDB \ Driver \ Command ($ doc );
665+ $ cmd = new Command ($ doc );
660666 $ manager ->executeCommand ('admin ' , $ cmd );
661667}
662668
663- function failMaxTimeMS (MongoDB \ Driver \ Manager $ manager )
669+ function failMaxTimeMS (Manager $ manager )
664670{
665671 configureFailPoint ($ manager , 'maxTimeAlwaysTimeOut ' , [ 'times ' => 1 ]);
666672}
@@ -694,7 +700,7 @@ function fromJSON($var) {
694700
695701/* Note: this fail point may terminate the mongod process, so you may want to
696702 * use this in conjunction with a throwaway server. */
697- function failGetMore (MongoDB \ Driver \ Manager $ manager )
703+ function failGetMore (Manager $ manager )
698704{
699705 /* We need to do version detection here */
700706 $ primary = $ manager ->selectServer (new ReadPreference ('primary ' ));
0 commit comments