function ModerationFormTest::testNonBundleModerationForm
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testNonBundleModerationForm()
- 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testNonBundleModerationForm()
- 10 core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testNonBundleModerationForm()
Tests moderation non-bundle entity type.
File
-
core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationFormTest.php, line 202
Class
- ModerationFormTest
- Tests the moderation form, specifically on nodes.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
public function testNonBundleModerationForm() : void {
$this->adminUser = $this->drupalCreateUser($this->getAdministratorPermissions());
$this->drupalLogin($this->adminUser);
$this->workflow
->getTypePlugin()
->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
$this->workflow
->save();
// Create new moderated content in draft.
$this->drupalGet('entity_test_mulrevpub/add');
$this->submitForm([
'moderation_state[0][state]' => 'draft',
], 'Save');
// The latest version page should not show, because there is no pending
// revision.
$this->drupalGet('/entity_test_mulrevpub/manage/1/latest');
$this->assertSession()
->statusCodeEquals(403);
// Update the draft.
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
$this->submitForm([
'moderation_state[0][state]' => 'draft',
], 'Save');
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet('/entity_test_mulrevpub/manage/1/latest');
$this->assertSession()
->statusCodeEquals(403);
// Publish the draft.
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
$this->submitForm([
'moderation_state[0][state]' => 'published',
], 'Save');
// The published view should not have a moderation form, because it is the
// default revision.
$this->drupalGet('entity_test_mulrevpub/manage/1');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextNotContains('Status');
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertSession()
->statusCodeEquals(403);
// Make a pending revision.
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
$this->submitForm([
'moderation_state[0][state]' => 'draft',
], 'Save');
// The published view should not have a moderation form, because it is the
// default revision.
$this->drupalGet('entity_test_mulrevpub/manage/1');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextNotContains('Status');
// The latest version page should show the moderation form and have "Draft"
// status, because the pending revision is in "Draft".
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('Moderation state');
$this->assertSession()
->pageTextContains('Draft');
// Submit the moderation form to change status to published.
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->submitForm([
'new_state' => 'published',
], 'Apply');
// The latest version page should not show, because there is no
// pending revision.
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertSession()
->statusCodeEquals(403);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.