You are here

public function PreviewLinkEntityTest::testSetEntities in Preview Link 2.x

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/PreviewLinkEntityTest.php \Drupal\Tests\preview_link\Kernel\PreviewLinkEntityTest::testSetEntities()

Tests setting entities.

@covers ::setEntities

File

tests/src/Kernel/PreviewLinkEntityTest.php, line 44

Class

PreviewLinkEntityTest
Preview link session test.

Namespace

Drupal\Tests\preview_link\Kernel

Code

public function testSetEntities() : void {
  $previewLink = PreviewLink::create();
  $entity = EntityTestRevPub::create();
  $previewLink
    ->setEntities([
    $entity,
  ]);
  $this
    ->assertCount(1, $previewLink->entities
    ->referencedEntities());
  $previewLink
    ->setEntities([
    $entity,
  ]);

  // Using setter should override previous values, therefore count is same.
  $this
    ->assertCount(1, $previewLink->entities
    ->referencedEntities());
}