You are here

public function MongodbCommands::mongodbCleanTests in MongoDB 8.2

Drop the Simpletest leftover collections.

@command mongodb:clean-tests @aliases mdct,mo-clean

@usage drush mongodb:clean-tests Clean test results after "bash tests.bash".

File

modules/mongodb/src/Commands/MongodbCommands.php, line 41

Class

MongodbCommands
Drush 9 commands service for the mongodb module.

Namespace

Drupal\mongodb\Commands

Code

public function mongodbCleanTests() {
  $dbs = array_keys($this->tools
    ->settings()['databases']);
  foreach ($dbs as $dbAlias) {

    /** @var \MongoDB\Collection[] $collections */
    $collections = $this->tools
      ->listCollections($dbAlias, "/^simpletest/");
    foreach ($collections as $collection) {
      $this
        ->logger()
        ->notice("Dropping {collectionName}", [
        'collectionName' => $collection
          ->getCollectionName(),
      ]);
      $collection
        ->drop();
    }
  }
}