You are here

public function FieldFormatterTest::testThirdPartySettings in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/FieldFormatterTest.php \Drupal\Tests\field\Kernel\FieldFormatterTest::testThirdPartySettings()
  2. 9 core/modules/field/tests/src/Kernel/FieldFormatterTest.php \Drupal\Tests\field\Kernel\FieldFormatterTest::testThirdPartySettings()

Tests availability of third party settings in field render arrays.

File

core/modules/field/tests/src/Kernel/FieldFormatterTest.php, line 88

Class

FieldFormatterTest
Tests for field formatters.

Namespace

Drupal\Tests\field\Kernel

Code

public function testThirdPartySettings() {
  $third_party_settings = [
    'field_test' => [
      'foo' => 'bar',
    ],
  ];
  $component = $this->display
    ->getComponent($this->fieldName);
  $component['third_party_settings'] = $third_party_settings;
  $this->display
    ->setComponent($this->fieldName, $component)
    ->save();
  $entity = EntityTestRev::create([]);
  $entity->{$this->fieldName}->value = $this
    ->randomString();
  $build = $entity->{$this->fieldName}
    ->view('default');
  $this
    ->assertEquals($third_party_settings, $build['#third_party_settings']);
}