/** * @depends testDropExistingCollection */ public function testDropNonexistentCollection() { $server = $this->getPrimaryServer(); $this->assertCollectionDoesNotExist($server, $this->getDatabaseName(), $this->getCollectionName()); $operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName()); $operation->execute($server); }
public function tearDown() { if ($this->hasFailed()) { return; } $operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName()); $operation->execute($this->getPrimaryServer()); }
public function testListIndexesForNonexistentCollection() { $operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName()); $operation->execute($this->getPrimaryServer()); $operation = new ListIndexes($this->getDatabaseName(), $this->getCollectionName()); $indexes = $operation->execute($this->getPrimaryServer()); $this->assertCount(0, $indexes); }
public function testAggregateWithOut() { $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); if (!\MongoDB\server_supports_feature($server, self::$wireVersionForOutOperator)) { $this->markTestSkipped('$out aggregation pipeline operator is not supported'); } $outputCollection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName() . '_output'); $operation = new DropCollection($this->getDatabaseName(), $outputCollection->getCollectionName()); $operation->execute($this->getPrimaryServer()); $this->collection->aggregate([['$sort' => ['x' => 1]], ['$match' => ['_id' => ['$gt' => 1]]], ['$out' => $outputCollection->getCollectionName()]]); $expected = [['_id' => 2, 'x' => 22], ['_id' => 3, 'x' => 33]]; $this->assertSameDocuments($expected, $outputCollection->find()); // Manually clean up our output collection $operation = new DropCollection($this->getDatabaseName(), $outputCollection->getCollectionName()); $operation->execute($this->getPrimaryServer()); }
/** * Drop this collection. * * @return object Command result document */ public function drop() { $operation = new DropCollection($this->databaseName, $this->collectionName); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }
/** * Drop a collection within this database. * * @see DropCollection::__construct() for supported options * @param string $collectionName Collection name * @param array $options Additional options * @return array|object Command result document */ public function dropCollection($collectionName, array $options = []) { if (!isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $operation = new DropCollection($this->databaseName, $collectionName, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }