You are here

protected function FileMetadataManagerTestBase::countMetadataKeys in File metadata manager 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/FileMetadataManagerTestBase.php \Drupal\Tests\file_mdm\Kernel\FileMetadataManagerTestBase::countMetadataKeys()

Returns the count of metadata keys found in the file.

Parameters

\Drupal\file_mdm\FileMetadataInterface $file_md: The FileMetadata object.

string $metadata_id: The file metadata plugin id.

mixed $options: (optional) Allows specifying additional options to control the list of metadata keys returned.

Return value

int The count of metadata keys found in the file.

9 calls to FileMetadataManagerTestBase::countMetadataKeys()
FileMetadataExifTest::testExifPlugin in file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php
Test EXIF plugin.
FileMetadataExifTest::testJpegExifSaveToFile in file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php
Test writing metadata to JPEG file.
FileMetadataExifTest::testTiffExifSaveToFile in file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php
Test writing metadata to TIFF file.
FileMetadataFontTest::testFontPlugin in file_mdm_font/tests/src/Kernel/FileMetadataFontTest.php
Test 'font' plugin.
FileMetadataManagerTest::testFileMetadata in tests/src/Kernel/FileMetadataManagerTest.php
Tests using the 'getimagesize' plugin.

... See full list

File

tests/src/Kernel/FileMetadataManagerTestBase.php, line 43

Class

FileMetadataManagerTestBase
Base test class for File Metadata Manager.

Namespace

Drupal\Tests\file_mdm\Kernel

Code

protected function countMetadataKeys(FileMetadataInterface $file_md, $metadata_id, $options = NULL) {
  $supported_keys = $file_md
    ->getSupportedKeys($metadata_id, $options);
  $count = 0;
  foreach ($supported_keys as $key) {
    if ($file_md
      ->getMetadata($metadata_id, $key)) {
      $count++;
    }
  }
  return $count;
}