public function PreviewLinkNodeTest::testReferenceUnpublishedNode in Preview Link 2.0.x
Same name and namespace in other branches
- 2.x tests/src/Functional/PreviewLinkNodeTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkNodeTest::testReferenceUnpublishedNode()
Tests referencing an unpublished node.
File
- tests/
src/ Functional/ PreviewLinkNodeTest.php, line 37
Class
- PreviewLinkNodeTest
- Tests nodes are referencable.
Namespace
Drupal\Tests\preview_link\FunctionalCode
public function testReferenceUnpublishedNode() : void {
$this
->createContentType([
'type' => 'page',
]);
$this
->drupalLogin($this
->createUser([
'generate preview links',
'access content',
]));
$node1 = $this
->createNode([
'title' => 'node1',
'status' => NodeInterface::NOT_PUBLISHED,
]);
$node2 = $this
->createNode([
'title' => 'node2',
'status' => NodeInterface::NOT_PUBLISHED,
]);
$generateUrl = $node1
->toUrl('preview-link-generate');
$this
->drupalGet($generateUrl);
$edit = [
'entities[1][target_id]' => 'node2 (' . $node2
->id() . ')',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// This would fail if unpublished wasnt referencable:
$this
->assertSession()
->pageTextContains('Preview Link saved.');
}