function MediaThumbnailFormatterTest::testSettingsSummary

Same name in other branches
  1. 10 core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php \Drupal\Tests\media\Kernel\MediaThumbnailFormatterTest::testSettingsSummary()
  2. 11.x core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php \Drupal\Tests\media\Kernel\MediaThumbnailFormatterTest::testSettingsSummary()

Tests the settings summary.

@covers ::settingsSummary

@dataProvider providerTestSettingsSummary

Parameters

array $settings: The settings to use for the formatter.

array $expected_summary: The expected settings summary.

File

core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php, line 77

Class

MediaThumbnailFormatterTest
@coversDefaultClass \Drupal\media\Plugin\Field\FieldFormatter\MediaThumbnailFormatter @group media

Namespace

Drupal\Tests\media\Kernel

Code

public function testSettingsSummary(array $settings, array $expected_summary) : void {
    
    /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display  */
    $display = \Drupal::service('entity_display.repository')->getViewDisplay($this->testEntityTypeId, $this->testEntityBundleId);
    $display->setComponent($this->mediaFieldName, [
        'type' => 'media_thumbnail',
        'settings' => $settings,
    ]);
    $formatter = $display->getRenderer($this->mediaFieldName);
    $actual_summary = array_map('strval', $formatter->settingsSummary());
    $this->assertSame($expected_summary, $actual_summary);
}

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