You are here

public function StateFormatterTest::testStateFieldFormatter in Drupal 10

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

Tests the embed field.

@dataProvider formatterTestCases

File

core/modules/content_moderation/tests/src/Kernel/StateFormatterTest.php, line 51

Class

StateFormatterTest
Test the state field formatter.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testStateFieldFormatter($field_value, $formatter_settings, $expected_output) {
  $entity = EntityTestRev::create([
    'moderation_state' => $field_value,
  ]);
  $entity
    ->save();
  $field_output = $this->container
    ->get('renderer')
    ->executeInRenderContext(new RenderContext(), function () use ($entity, $formatter_settings) {
    return $entity->moderation_state
      ->view($formatter_settings);
  });
  $this
    ->assertEquals($expected_output, $field_output[0]);
}