PreviewLinkNodeTest.php in Preview Link 2.0.x
File
tests/src/Functional/PreviewLinkNodeTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\preview_link\Functional;
use Drupal\node\NodeInterface;
use Drupal\Tests\BrowserTestBase;
class PreviewLinkNodeTest extends BrowserTestBase {
protected $defaultTheme = 'classy';
public static $modules = [
'dynamic_entity_reference',
'preview_link',
'node',
];
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
->assertSession()
->pageTextContains('Preview Link saved.');
}
}