You are here

public function FieldOutputTest::testFieldOutput in Fences 8.2

Test the field output.

@dataProvider fieldTestCases

File

tests/src/Kernel/FieldOutputTest.php, line 163

Class

FieldOutputTest
Test the field output under different configurations.

Namespace

Drupal\Tests\fences\Kernel

Code

public function testFieldOutput($settings, $label_visible, $field_markup) {

  // The entity display must be updated because the view method on fields
  // doesn't support passing third party settings.
  $this->entityViewDisplay
    ->setComponent($this->fieldName, [
    'label' => $label_visible ? 'above' : 'hidden',
    'settings' => [],
    'type' => 'text_default',
    'third_party_settings' => [
      'fences' => $settings,
    ],
  ])
    ->setStatus(TRUE)
    ->save();
  $field_output = $this->entity->{$this->fieldName}
    ->view('default');
  $rendered_field_output = $this
    ->stripWhitespace($this->container
    ->get('renderer')
    ->renderRoot($field_output));
  $this
    ->assertEquals($this
    ->stripWhitespace($field_markup), $rendered_field_output);
}