You are here

protected function MongoDBLogTestCase::getSeverityConstant in MongoDB 8

Same name and namespace in other branches
  1. 6 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::getSeverityConstant()
  2. 7 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::getSeverityConstant()

Get the watchdog severity constant corresponding to the CSS class.

Parameters

$class: CSS class attribute.

Return value

The watchdog severity constant or NULL if not found.

1 call to MongoDBLogTestCase::getSeverityConstant()
MongoDBLogTestCase::getLogEntries in mongodb_watchdog/mongodb_watchdog.test
Get the log entry information form the page.

File

mongodb_watchdog/mongodb_watchdog.test, line 670
Test class for MongoDB_watchdog.

Class

MongoDBLogTestCase
Test the behaviour of watchdog() mongodb_watchdog, not dblog

Code

protected function getSeverityConstant($class) {

  // Reversed array from dblog_overview().
  $map = array(
    'dblog-debug' => WATCHDOG_DEBUG,
    'dblog-info' => WATCHDOG_INFO,
    'dblog-notice' => WATCHDOG_NOTICE,
    'dblog-warning' => WATCHDOG_WARNING,
    'dblog-error' => WATCHDOG_ERROR,
    'dblog-critical' => WATCHDOG_CRITICAL,
    'dblog-alert' => WATCHDOG_ALERT,
    'dblog-emerg' => WATCHDOG_EMERGENCY,
  );

  // Find the class that contains the severity.
  $classes = explode(' ', $class);
  foreach ($classes as $class) {
    if (isset($map[$class])) {
      return $map[$class];
    }
  }
  return NULL;
}