You are here

public function PanelsEverywhereTest::testCustomVariants in Panels Everywhere 8.4

Verify that multiple variants work.

File

tests/src/Functional/PanelsEverywhereTest.php, line 137

Class

PanelsEverywhereTest
Make sure that PE can be enabled.

Namespace

Drupal\Tests\panels_everywhere\Functional

Code

public function testCustomVariants() {
  $this
    ->enableSiteTemplate();
  $siteTemplate = $this
    ->loadSiteTemplate();
  $defaultVariant = $siteTemplate
    ->getVariant('panels_everywhere');
  $this
    ->addPathCondition($defaultVariant, '<front>', TRUE);
  $defaultVariant
    ->save();
  $this
    ->checkFrontPageWorks();
  $this
    ->assertSession()
    ->pageTextContains('No front page content has been created yet.');
  $customVariant = $this->pageVariantStorage
    ->create([
    'id' => 'this-is-a-custom-variant',
    'variant' => 'panels_everywhere_variant',
    'variant_settings' => [
      'id' => 'panels_everywhere_variant',
      'layout' => 'layout_onecol',
      'builder' => 'standard',
    ],
  ]);
  $customVariant
    ->setPageEntity($siteTemplate);
  $customVariant
    ->save();
  $this
    ->addPathCondition($customVariant, '<front>');

  // @todo: Remove once cache info is setup correctly
  drupal_flush_all_caches();
  $this
    ->checkFrontPageWorks();
  $this
    ->assertSession()
    ->pageTextNotContains('No front page content has been created yet.');
  $this->pageVariantStorage
    ->delete([
    $customVariant,
  ]);

  // @todo: Remove once cache info is setup correctly
  drupal_flush_all_caches();
  $this
    ->checkFrontPageWorks();
  $this
    ->assertSession()
    ->pageTextContains('No front page content has been created yet.');
}