You are here

protected function FormatterTestBase::assertFieldFormatter in Range 8

Asserts that field formatter does its job.

1 call to FormatterTestBase::assertFieldFormatter()
FormatterTestBase::testFieldFormatter in tests/src/Kernel/Formatter/FormatterTestBase.php
Tests formatter.

File

tests/src/Kernel/Formatter/FormatterTestBase.php, line 96

Class

FormatterTestBase
Base class for range functional integration tests.

Namespace

Drupal\Tests\range\Kernel\Formatter

Code

protected function assertFieldFormatter(array $display_settings, $from, $to, $expected) {
  $this->entity->{$this->fieldName} = [
    'from' => $from,
    'to' => $to,
  ];
  $content = $this->entity->{$this->fieldName}
    ->get(0)
    ->view([
    'type' => $this->displayType,
    'settings' => $display_settings,
  ]);
  $renderer = $this->container
    ->get('renderer');
  $this
    ->assertEquals($expected, $renderer
    ->renderRoot($content));
}