function FieldFormatterTest::testThirdPartySettings

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldFormatterTest.php \Drupal\Tests\field\Kernel\FieldFormatterTest::testThirdPartySettings()
  2. 8.9.x core/modules/field/tests/src/Kernel/FieldFormatterTest.php \Drupal\Tests\field\Kernel\FieldFormatterTest::testThirdPartySettings()
  3. 10 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 90

Class

FieldFormatterTest
Tests for field formatters.

Namespace

Drupal\Tests\field\Kernel

Code

public function testThirdPartySettings() : void {
    $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']);
}

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