You are here

function PanelizerTermTest::testTermPanelizeIt in Panelizer 7.3

File

tests/panelizer.term.test, line 123
Panelizer tests.

Class

PanelizerTermTest
Verifies Panelizer configuration options for taxonomy terms.

Code

function testTermPanelizeIt() {
  $view_mode = 'default';
  $view_mode_label = t('Default');
  $this
    ->togglePanelizer('taxonomy_term', $this->vocabulary->machine_name, $view_mode, 1, 0, 0);
  $term = $this
    ->createTestTerm();

  // Check that the view mode can be panelized.
  $this
    ->drupalGet('taxonomy/term/' . $term->tid . '/panelizer');
  $this
    ->assertResponse(200);
  $this
    ->assertText($view_mode_label);
  $this
    ->assertLink('panelize', 0, "The panelize link for the {$view_mode} view mode appears on the page.");
  $this
    ->assertLinkByHref('taxonomy/term/' . $term->tid . '/panelizer/' . $view_mode, 0, "A link to panelize the {$view_mode} view mode appears on the page.");

  // Verify that the view mode is not currently panelized.
  $this
    ->drupalGet('taxonomy/term/' . $term->tid . '/panelizer/' . $view_mode);
  $this
    ->assertResponse(200);
  $this
    ->assertRaw(t('This %entity is not currently panelized.', array(
    '%entity' => 'Taxonomy term',
  )));

  // Panelize the view mode.
  $this
    ->drupalPost(NULL, array(), t('Panelize it!'));
  $this
    ->assertResponse(200);

  // Check that the view mode has been panelized.
  $this
    ->drupalGet('taxonomy/term/' . $term->tid);
  $this
    ->assertResponse(200);
  $elements = $this
    ->xpath('//div[contains(@class,:class)]', array(
    ':class' => 'panelizer-view-mode',
  ));
  $this
    ->assertEqual(count($elements), 1, 'The term is panelized.');
}