function 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\KernelCode
public function testStateFieldFormatter($field_value, $formatter_settings, $expected_output) : void {
  $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]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.