Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

Commit

Permalink
Optional log checking
Browse files Browse the repository at this point in the history
  • Loading branch information
guncha25 committed Sep 28, 2017
1 parent baf2ad5 commit 0e71ac0
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/Codeception/Module/DrupalBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(ModuleContainer $container, $config = null) {
[
'drupal_root' => Configuration::projectDir() . 'web',
'site_path' => 'sites/default',
'check_logs' => False
],
(array)$config
);
Expand Down Expand Up @@ -75,20 +76,22 @@ public function _afterSuite() {
}
}

if (\Drupal::moduleHandler()->moduleExists('dblog')) {
// Load any database log entries of level WARNING or more serious.
$query = \Drupal::database()->select('watchdog', 'w');
$query->fields('w', ['type', 'severity', 'message', 'variables'])
->condition('severity', RfcLogLevel::NOTICE, '<=')
->condition('type', 'php');
$result = $query->execute();
foreach ($result as $row) {
// Build a readable message and declare a failure.
$variables = @unserialize($row->variables);
$message = $row->type . ' - ';
$message .= RfcLogLevel::getLevels()[$row->severity] . ': ';
$message .= t(Xss::filterAdmin($row->message), $variables)->render();
$this->fail($message);
if ($this->config['check_logs']) {
if (\Drupal::moduleHandler()->moduleExists('dblog')) {
// Load any database log entries of level WARNING or more serious.
$query = \Drupal::database()->select('watchdog', 'w');
$query->fields('w', ['type', 'severity', 'message', 'variables'])
->condition('severity', RfcLogLevel::NOTICE, '<=')
->condition('type', 'php');
$result = $query->execute();
foreach ($result as $row) {
// Build a readable message and declare a failure.
$variables = @unserialize($row->variables);
$message = $row->type . ' - ';
$message .= RfcLogLevel::getLevels()[$row->severity] . ': ';
$message .= t(Xss::filterAdmin($row->message), $variables)->render();
$this->fail($message);
}
}
}
}
Expand Down

0 comments on commit 0e71ac0

Please sign in to comment.