You are here

public function PanelizerTermFunctionalTest::testPanelizerDefault in Panelizer 8.3

Tests rendering a taxonomy term with Panelizer default.

File

src/Tests/PanelizerTermFunctionalTest.php, line 64

Class

PanelizerTermFunctionalTest
Basic functional tests of using Panelizer with taxonomy terms.

Namespace

Drupal\panelizer\Tests

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' => 'middle',
  ]);
  $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');
}