コード例 #1
0
 public function testListCollectionsForNonexistentDatabase()
 {
     $server = $this->getPrimaryServer();
     $operation = new DropDatabase($this->getDatabaseName());
     $operation->execute($server);
     $operation = new ListCollections($this->getDatabaseName());
     $collections = $operation->execute($server);
     $this->assertCount(0, $collections);
 }
コード例 #2
0
 /**
  * Asserts that a collection with the given name does not exist on the
  * server.
  *
  * @param Server $server
  * @param string $databaseName
  * @param string $collectionName
  */
 private function assertCollectionDoesNotExist(Server $server, $databaseName, $collectionName)
 {
     $operation = new ListCollections($databaseName);
     $collections = $operation->execute($server);
     $foundCollection = null;
     foreach ($collections as $collection) {
         if ($collection->getName() === $collectionName) {
             $foundCollection = $collection;
             break;
         }
     }
     $this->assertNull($foundCollection, sprintf('Collection %s exists on the server', $collectionName));
 }
コード例 #3
0
 /**
  * Returns information for all collections in this database.
  *
  * @see ListCollections::__construct() for supported options
  * @param array $options
  * @return CollectionInfoIterator
  */
 public function listCollections(array $options = [])
 {
     $operation = new ListCollections($this->databaseName, $options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }