You are here

public function WorkspacePointerTest::testCreationWithObject in Workspace 8

Verifies pointers can be created using an object as the reference.

File

tests/src/Kernel/WorkspacePointerTest.php, line 70

Class

WorkspacePointerTest
Tests for the WorkspacePointer entity.

Namespace

Drupal\Tests\workspace\Kernel

Code

public function testCreationWithObject() {
  $this
    ->createWorkspaceType();
  $workspace = $this
    ->createWorkspace();

  /** @var WorkspacePointer $pointer */
  $pointer = WorkspacePointer::create();
  $pointer
    ->setWorkspace($workspace);
  $pointer
    ->save();
  $id = $pointer
    ->id();
  $pointer = WorkspacePointer::load($id);
  $this
    ->assertEquals($workspace
    ->id(), $pointer
    ->getWorkspaceId());
  $this
    ->assertEquals($workspace
    ->id(), $pointer
    ->getWorkspace()
    ->id());
}