function MigrateMessageFormTest::getLevelCounts

Same name and namespace in other branches
  1. 10 core/modules/migrate/tests/src/Functional/MigrateMessageFormTest.php \Drupal\Tests\migrate\Functional\MigrateMessageFormTest::getLevelCounts()

Gets the count of migration messages by level.

Parameters

array $levels: The error levels to check.

Return value

array The count of each error level keyed by the error level.

1 call to MigrateMessageFormTest::getLevelCounts()
MigrateMessageFormTest::testFilter in core/modules/migrate/tests/src/Functional/MigrateMessageFormTest.php
Tests the message form.

File

core/modules/migrate/tests/src/Functional/MigrateMessageFormTest.php, line 63

Class

MigrateMessageFormTest
Tests for the MessageForm class.

Namespace

Drupal\Tests\migrate\Functional

Code

protected function getLevelCounts(array $levels) : array {
    $entries = $this->getMessages();
    $count = array_fill(1, count($levels), 0);
    foreach ($entries as $entry) {
        if (array_key_exists($entry['severity'], $levels)) {
            $count[$entry['severity']]++;
        }
    }
    return $count;
}

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