You are here

public function PageVariantPageEntityTest::testUnsavedPage in Page Manager 8.4

Same name and namespace in other branches
  1. 8 tests/src/Kernel/PageVariantPageEntityTest.php \Drupal\Tests\page_manager\Kernel\PageVariantPageEntityTest::testUnsavedPage()

Tests that a an unsaved page can be set against a page variant.

File

tests/src/Kernel/PageVariantPageEntityTest.php, line 45

Class

PageVariantPageEntityTest
Tests storing an page entity on a page variant.

Namespace

Drupal\Tests\page_manager\Kernel

Code

public function testUnsavedPage() {

  /* @var \Drupal\page_manager\PageInterface $page */
  $page = Page::create([
    'id' => 'test_page',
  ]);

  /* @var \Drupal\page_manager\PageVariantInterface $page_variant */
  $page_variant = PageVariant::create([
    'id' => 'test_page_variant',
    'page' => 'test_page',
  ]);
  $page_variant
    ->setPageEntity($page);

  // Get the page from the variant.
  $page_result = $page_variant
    ->getPage();
  $this
    ->assertEquals($page, $page_result);
}