You are here

protected function FormatterDependenciesTest::assertFormatterDependencyBehavior in Video Embed Field 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/FormatterDependenciesTest.php \Drupal\Tests\video_embed_field\Kernel\FormatterDependenciesTest::assertFormatterDependencyBehavior()

Assert the behavior of the formatter dependencies.

Parameters

array $formatter_settings: The formatter settings to apply to the entity dispaly.

2 calls to FormatterDependenciesTest::assertFormatterDependencyBehavior()
FormatterDependenciesTest::testColorboxConfigDependencies in tests/src/Kernel/FormatterDependenciesTest.php
Test dependencies are created correctly added for the colorbox formatter.
FormatterDependenciesTest::testThumbnailConfigDependencies in tests/src/Kernel/FormatterDependenciesTest.php
Test dependencies are created correctly added for the image formatter.

File

tests/src/Kernel/FormatterDependenciesTest.php, line 79

Class

FormatterDependenciesTest
Test the configuration dependencies are created correctly.

Namespace

Drupal\Tests\video_embed_field\Kernel

Code

protected function assertFormatterDependencyBehavior($formatter_settings) {

  // Assert the image style becomes a dependency of the entity display.
  $this
    ->loadEntityDisplay()
    ->setComponent($this->fieldName, $formatter_settings)
    ->save();
  $this
    ->assertTrue(in_array('image.style.' . $this->style
    ->id(), $this
    ->loadEntityDisplay()
    ->getDependencies()['config']), 'The image style was correctly added as a dependency the entity display config object.');

  // Delete the image style.
  $storage = $this->entityTypeManager
    ->getStorage('image_style');
  $storage
    ->setReplacementId($this->style
    ->id(), $this->replacementStyle
    ->id());
  $this->style
    ->delete();

  // Ensure the replacement is now a dependency.
  $this
    ->assertTrue(in_array('image.style.' . $this->replacementStyle
    ->id(), $this
    ->loadEntityDisplay()
    ->getDependencies()['config']), 'The replacement style was added to the entity display.');
}