You are here

public function ModerationFormTest::testAlternativeModerationStateWidget in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testAlternativeModerationStateWidget()

Tests the moderation_state field when an alternative widget is set.

File

core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php, line 492

Class

ModerationFormTest
Tests the moderation form, specifically on nodes.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testAlternativeModerationStateWidget() {
  $entity_form_display = EntityFormDisplay::load('node.moderated_content.default');
  $entity_form_display
    ->setComponent('moderation_state', [
    'type' => 'string_textfield',
    'region' => 'content',
  ]);
  $entity_form_display
    ->save();
  $this
    ->drupalGet('node/add/moderated_content');
  $this
    ->submitForm([
    'title[0][value]' => 'Test content',
    'moderation_state[0][value]' => 'published',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Moderated content Test content has been created.');
}