/**
  * Asserts that a database with the given name does not exist on the server.
  *
  * @param Server $server
  * @param string $databaseName
  */
 private function assertDatabaseDoesNotExist(Server $server, $databaseName)
 {
     $operation = new ListDatabases();
     $databases = $operation->execute($server);
     $foundDatabase = null;
     foreach ($databases as $database) {
         if ($database->getName() === $databaseName) {
             $foundDatabase = $database;
             break;
         }
     }
     $this->assertNull($foundDatabase, sprintf('Database %s exists on the server', $databaseName));
 }
 /**
  * List databases.
  *
  * @see ListDatabases::__construct() for supported options
  * @return DatabaseInfoIterator
  */
 public function listDatabases(array $options = array())
 {
     $operation = new ListDatabases($options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }