function DefaultModerationStateTest::testPublishedDefaultState

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/DefaultModerationStateTest.php \Drupal\Tests\content_moderation\Functional\DefaultModerationStateTest::testPublishedDefaultState()
  2. 10 core/modules/content_moderation/tests/src/Functional/DefaultModerationStateTest.php \Drupal\Tests\content_moderation\Functional\DefaultModerationStateTest::testPublishedDefaultState()
  3. 11.x core/modules/content_moderation/tests/src/Functional/DefaultModerationStateTest.php \Drupal\Tests\content_moderation\Functional\DefaultModerationStateTest::testPublishedDefaultState()

Test a workflow with a default moderation state set.

File

core/modules/content_moderation/tests/src/Functional/DefaultModerationStateTest.php, line 30

Class

DefaultModerationStateTest
Tests setting a custom default moderation state.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testPublishedDefaultState() {
    // Set the default moderation state to be "published".
    $this->drupalPostForm('admin/config/workflow/workflows/manage/' . $this->workflow
        ->id(), [
        'type_settings[workflow_settings][default_moderation_state]' => 'published',
    ], 'Save');
    $this->drupalGet('node/add/moderated_content');
    $this->assertEquals('published', $this->assertSession()
        ->selectExists('moderation_state[0][state]')
        ->getValue());
    $this->submitForm([
        'title[0][value]' => 'moderated content',
    ], 'Save');
    $node = $this->getNodeByTitle('moderated content');
    $this->assertEquals('published', $node->moderation_state->value);
}

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