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); }
/** * 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)); }
/** * 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); }