function ModerationFormTest::testModerationFormSetsRevisionAuthor
Same name in other branches
- 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testModerationFormSetsRevisionAuthor()
- 10 core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testModerationFormSetsRevisionAuthor()
- 11.x core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php \Drupal\Tests\content_moderation\Functional\ModerationFormTest::testModerationFormSetsRevisionAuthor()
Tests the revision author is updated when the moderation form is used.
File
-
core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationFormTest.php, line 255
Class
- ModerationFormTest
- Tests the moderation form, specifically on nodes.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
public function testModerationFormSetsRevisionAuthor() {
// Create new moderated content in published.
$node = $this->createNode([
'type' => 'moderated_content',
'moderation_state' => 'published',
]);
// Make a pending revision.
$node->title = $this->randomMachineName();
$node->moderation_state->value = 'draft';
$node->setRevisionCreationTime(12345);
$node->save();
$another_user = $this->drupalCreateUser($this->permissions);
$this->grantUserPermissionToCreateContentOfType($another_user, 'moderated_content');
$this->drupalLogin($another_user);
$this->drupalGet(sprintf('node/%d/latest', $node->id()));
$this->submitForm([
'new_state' => 'published',
], 'Apply');
$this->drupalGet(sprintf('node/%d/revisions', $node->id()));
$this->assertSession()
->pageTextContains('by ' . $another_user->getAccountName());
// Verify the revision creation time has been updated.
$node = $node->load($node->id());
$this->assertGreaterThan(12345, $node->getRevisionCreationTime());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.