function DbLogTest::getTypeCount

Same name and namespace in other branches
  1. 9 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::getTypeCount()
  2. 8.9.x core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::getTypeCount()
  3. 10 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::getTypeCount()

Gets the count of database log entries by database log event 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.

1 call to DbLogTest::getTypeCount()
DbLogTest::testFilter in core/modules/dblog/tests/src/Functional/DbLogTest.php
Tests the database log filter functionality at admin/reports/dblog.

File

core/modules/dblog/tests/src/Functional/DbLogTest.php, line 773

Class

DbLogTest
Verifies log entries and user access based on permissions.

Namespace

Drupal\Tests\dblog\Functional

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.