You are here

function PanelizerTermTest::testVocabularyConfiguration in Panelizer 7.3

Test the vocabulary configuration functionality.

File

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

Class

PanelizerTermTest
Verifies Panelizer configuration options for taxonomy terms.

Code

function testVocabularyConfiguration() {

  // Load the vocabulary's settings page.
  $this
    ->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit');
  $this
    ->assertResponse(200);

  // Confirm that the appropriate fields are present.
  $this
    ->assertFieldByName('panelizer[status]');
  $this
    ->assertFieldByName('panelizer[help]');
  foreach (array(
    'page_manager',
    'default',
  ) as $view_mode) {
    $this
      ->assertFieldByName('panelizer[view modes][' . $view_mode . '][status]');
    $this
      ->assertFieldByName('panelizer[view modes][' . $view_mode . '][default]');
    $this
      ->assertFieldByName('panelizer[view modes][' . $view_mode . '][choice]');
  }

  // Panelize the test vocabulary.
  $edit = array(
    'panelizer[status]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->assertResponse(200);
  $term = $this
    ->createTestTerm();

  // Verify the term can be panelized.
  $this
    ->drupalGet('taxonomy/term/' . $term->tid);
  $this
    ->assertResponse(200);
  $this
    ->assertLink('Customize display', 0, 'The customize display link appears on the page');
  $this
    ->assertLinkByHref('taxonomy/term/' . $term->tid . '/panelizer', 0, 'A link to customize the node appears on the page');

  // Allow panelization of the "Default" view mode.
  $edit = array(
    'panelizer[view modes][default][status]' => TRUE,
    'panelizer[view modes][default][default]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/panelizer_vocabulary/edit', $edit, t('Save'));
  $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.');
}