/** * Drop the collection if it exists. * * @param Collection $collection */ protected function dropCollectionIfItExists(Collection $collection) { $database = new Database($this->manager, $collection->getDatabaseName()); $collections = $database->listCollections(array('filter' => array('name' => $collection->getCollectionName()))); if (iterator_count($collections) > 0) { $this->assertCommandSucceeded($collection->drop()); } }