You are here

protected function ThunderTestTrait::tearDown in Thunder 6.0.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()
  2. 8.2 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()
  3. 8.3 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()
  4. 8.4 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()
  5. 6.2.x tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()
  6. 6.1.x tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::tearDown()

File

tests/src/Traits/ThunderTestTrait.php, line 142

Class

ThunderTestTrait
Use this trait to reuse an existing database.

Namespace

Drupal\Tests\thunder\Traits

Code

protected function tearDown() {

  /** @var \Drupal\Core\Database\Query\SelectInterface $query */
  $query = \Drupal::database()
    ->select('watchdog', 'w')
    ->fields('w', [
    'message',
    'variables',
  ]);
  $andGroup = $query
    ->andConditionGroup()
    ->condition('severity', 5, '<')
    ->condition('type', 'php');
  $group = $query
    ->orConditionGroup()
    ->condition('severity', 4, '<')
    ->condition($andGroup);
  $query
    ->condition($group);
  $query
    ->groupBy('w.message');
  $query
    ->groupBy('w.variables');
  $controller = DbLogController::create($this->container);

  // Check that there are no warnings in the log after installation.
  // $this->assertEqual($query->countQuery()->execute()->fetchField(), 0);.
  if ($query
    ->countQuery()
    ->execute()
    ->fetchField()) {

    // Output all errors for modules tested.
    $errors = [];
    foreach ($query
      ->execute()
      ->fetchAll() as $row) {
      $errors[] = Unicode::truncate(Html::decodeEntities(strip_tags($controller
        ->formatMessage($row))), 256, TRUE, TRUE);
    }
    throw new \Exception(print_r($errors, TRUE));
  }
  parent::tearDown();
}