You are here

protected function MongoDBLogTestCase::getTypeCount in MongoDB 6

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

Get the count of entries per type.

Parameters

array $types: The type information to compare against.

Return value

array The count of each type keyed by the key of the $types array.

File

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

Class

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

Code

protected function getTypeCount(array $types) {
  $entries = $this
    ->getLogEntries();
  $count = array_fill(0, count($types), 0);
  foreach ($entries as $entry) {
    foreach ($types as $key => $type) {
      if ($entry['type'] == $type['type'] && $entry['severity'] == $type['severity']) {
        $count[$key]++;
        break;
      }
    }
  }
  return $count;
}