function FileListingTest::sumUsages

Same name in other branches
  1. 8.9.x core/modules/file/tests/src/Functional/FileListingTest.php \Drupal\Tests\file\Functional\FileListingTest::sumUsages()
  2. 10 core/modules/file/tests/src/Functional/FileListingTest.php \Drupal\Tests\file\Functional\FileListingTest::sumUsages()
  3. 11.x core/modules/file/tests/src/Functional/FileListingTest.php \Drupal\Tests\file\Functional\FileListingTest::sumUsages()

Calculates total count of usages for a file.

Parameters

$usage array: Array of file usage information as returned from file_usage subsystem.

Return value

int Total usage count.

1 call to FileListingTest::sumUsages()
FileListingTest::testFileListingPages in core/modules/file/tests/src/Functional/FileListingTest.php
Tests file overview with different user permissions.

File

core/modules/file/tests/src/Functional/FileListingTest.php, line 63

Class

FileListingTest
Tests file listing page functionality.

Namespace

Drupal\Tests\file\Functional

Code

protected function sumUsages($usage) {
    $count = 0;
    foreach ($usage as $module) {
        foreach ($module as $entity_type) {
            foreach ($entity_type as $entity) {
                $count += $entity;
            }
        }
    }
    return $count;
}

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