You are here

public function PageVariantPageEntityTest::testChangePageId 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::testChangePageId()

Tests that a page gets cached on the page variant.

File

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

Class

PageVariantPageEntityTest
Tests storing an page entity on a page variant.

Namespace

Drupal\Tests\page_manager\Kernel

Code

public function testChangePageId() {

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

  // Check the page gets set correctly.

  /* @var \Drupal\page_manager\PageInterface $page */
  $page1 = Page::create([
    'id' => 'test_page_1',
  ]);
  $page_variant
    ->setPageEntity($page1);
  $this
    ->assertEquals('test_page_1', $page_variant
    ->get('page'));

  // Check the page gets changed correctly.

  /* @var \Drupal\page_manager\PageInterface $page */
  $page2 = Page::create([
    'id' => 'test_page_2',
  ]);
  $page_variant
    ->setPageEntity($page2);
  $this
    ->assertEquals('test_page_2', $page_variant
    ->get('page'));
}