You are here

function drush_mongodb_clean_tests in MongoDB 7

Drush callback: drop the Simpletest leftover collections.

Throws

\MongoConnectionException

File

./mongodb.drush.inc, line 179
Provide drush integration for MongoDB.

Code

function drush_mongodb_clean_tests() {

  /* @var \MongoDB $mongo */
  $mongo = mongodb();
  $names = $mongo
    ->getCollectionNames();
  $count = 0;
  foreach ($names as $name) {
    if (strpos($name, 'simpletest') === 0) {
      $mongo
        ->dropCollection($name);
      $count++;
    }
  }
  drush_print(dt('Dropped @count collections.', [
    '@count' => $count,
  ]));
}