public function PreviewLinkForwardRevisionTest::testForwardRevision in Preview Link 8
Same name and namespace in other branches
- 2.x tests/src/Functional/PreviewLinkForwardRevisionTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkForwardRevisionTest::testForwardRevision()
- 2.0.x tests/src/Functional/PreviewLinkForwardRevisionTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkForwardRevisionTest::testForwardRevision()
Test the latest forward revision is loaded.
File
- tests/
src/ Functional/ PreviewLinkForwardRevisionTest.php, line 59
Class
- PreviewLinkForwardRevisionTest
- Test forward revisions are loaded.
Namespace
Drupal\Tests\preview_link\FunctionalCode
public function testForwardRevision() {
$original_random_text = 'Original Title';
$latest_random_text = 'Latest Title';
// Create a node with some random text.
$node = $this
->createNode([
'title' => $original_random_text,
'moderation_state' => 'published',
]);
// Create a forward revision with new text.
$node
->setTitle($latest_random_text);
$node->moderation_state = 'draft';
$node
->save();
// Create the preview link.
$previewLink = PreviewLink::create([
'entity_type_id' => 'node',
'entity_id' => $node
->id(),
]);
$previewLink
->save();
// Visit the node and assert the original text.
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextNotContains($latest_random_text);
$this
->assertSession()
->pageTextContains($original_random_text);
// Visit the preview link and assert the forward revision text.
$this
->drupalGet($previewLink
->getUrl());
$this
->assertSession()
->pageTextContains($latest_random_text);
$this
->assertSession()
->pageTextNotContains($original_random_text);
}