You are here

public function PreviewLinkTest::testEntitiesUniqueConstraint in Preview Link 2.0.x

Same name and namespace in other branches
  1. 2.x tests/src/Functional/PreviewLinkTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkTest::testEntitiesUniqueConstraint()

Tests unique entities for Preview Link.

File

tests/src/Functional/PreviewLinkTest.php, line 208

Class

PreviewLinkTest
Integration test for the preview link.

Namespace

Drupal\Tests\preview_link\Functional

Code

public function testEntitiesUniqueConstraint() : void {
  $this
    ->drupalLogin($this
    ->createUser([
    'generate preview links',
    'view test entity',
  ]));
  $entity = EntityTestRevPub::create([
    'name' => 'foo1',
  ]);
  $entity
    ->save();
  $generateUrl = $entity
    ->toUrl('preview-link-generate');
  $this
    ->drupalGet($generateUrl);
  $edit = [
    'entities[0][target_id]' => 'foo1 (1)',
    'entities[1][target_id]' => 'foo1 (1)',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('test entity - revisions and publishing status is already referenced by item #1.');
}