function ModerationFormTest::testAlternativeModerationStateWidget

Same name in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testAlternativeModerationStateWidget()
  2. 10 core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testAlternativeModerationStateWidget()
  3. 11.x 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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.