You are here

public function PageVariantPageEntityTest::testPageGetsCached in Page Manager 8

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

Tests that a page gets cached on the page variant.

File

tests/src/Kernel/PageVariantPageEntityTest.php, line 29
Contains \Drupal\Tests\page_manager\Kernel\PageVariantPageEntityTest.

Class

PageVariantPageEntityTest
Tests storing an page entity on a page variant.

Namespace

Drupal\Tests\page_manager\Kernel

Code

public function testPageGetsCached() {

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

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

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