You are here

public function BlazyAdminFormatterUnitTest::testGetSettingsSummary in Blazy 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/Form/BlazyAdminFormatterUnitTest.php \Drupal\Tests\blazy\Unit\Form\BlazyAdminFormatterUnitTest::testGetSettingsSummary()

Tests the Blazy admin ::getSettingsSummary().

@dataProvider providerTestGetSettingsSummary

File

tests/src/Unit/Form/BlazyAdminFormatterUnitTest.php, line 97

Class

BlazyAdminFormatterUnitTest
Tests the Blazy admin formatter form.

Namespace

Drupal\Tests\blazy\Unit\Form

Code

public function testGetSettingsSummary($use_settings, $vanilla, $override, $responsive_image_style, $expected) {
  $definition = $this
    ->getFormatterDefinition();
  $settings = array_merge(BlazyDefault::gridSettings(), $definition['settings']);
  $settings['vanilla'] = $vanilla;
  $settings['image_syle'] = 'large';
  $settings['box_style'] = 'blazy_crop';
  $settings['thumbnail_style'] = 'thumbnail';
  $settings['optionset'] = 'default';
  $settings['override'] = $override;
  $settings['overridables'] = [
    'foo' => 'foo',
    'bar' => '0',
  ];
  $settings['responsive_image_style'] = $responsive_image_style;
  $settings['caption'] = [
    'alt' => 'alt',
    'title' => 'title',
  ];
  $settings['breakpoints'] = $this
    ->getDataBreakpoints(TRUE);
  $definition['settings'] = $use_settings ? $settings : [];
  $summary = $this->blazyAdminFormatter
    ->getSettingsSummary($definition);
  $summary = array_filter($summary);
  $check_summary = !$expected ? empty($summary) : !empty($summary);
  $this
    ->assertTrue($check_summary);
}