You are here

public function PanelizerTermFunctionalTest::testPanelizerDefault in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/PanelizerTermFunctionalTest.php \Drupal\Tests\panelizer\Functional\PanelizerTermFunctionalTest::testPanelizerDefault()

Tests rendering a taxonomy term with Panelizer default.

File

tests/src/Functional/PanelizerTermFunctionalTest.php, line 78

Class

PanelizerTermFunctionalTest
Basic functional tests of using Panelizer with taxonomy terms.

Namespace

Drupal\Tests\panelizer\Functional

Code

public function testPanelizerDefault() {

  /** @var \Drupal\panelizer\PanelizerInterface $panelizer */
  $panelizer = \Drupal::service('panelizer');
  $displays = $panelizer
    ->getDefaultPanelsDisplays('taxonomy_term', 'tags', 'default');
  $display = $displays['default'];
  $display
    ->addBlock([
    'id' => 'panelizer_test',
    'label' => 'Panelizer test',
    'provider' => 'block_content',
    'region' => 'content',
  ]);
  $panelizer
    ->setDefaultPanelsDisplay('default', 'taxonomy_term', 'tags', 'default', $display);

  // Create a term, and check that the IPE is visible on it.
  $term = $this
    ->createTerm();
  $out = $this
    ->drupalGet('taxonomy/term/' . $term
    ->id());
  $this
    ->assertResponse(200);
  $this
    ->verbose($out);
  $elements = $this
    ->xpath('//*[@id="panels-ipe-content"]');
  if (is_array($elements)) {
    $this
      ->assertIdentical(count($elements), 1);
  }
  else {
    $this
      ->fail('Could not parse page content.');
  }

  // Check that the block we added is visible.
  $this
    ->assertText('Panelizer test');
  $this
    ->assertText('Abracadabra');
}