You are here

public function TaxonomyMenuConfigurationTest::testTaxonomyMenuTermDescriptionOption in Taxonomy menu 7.2

Tests Taxonommy Menu "Term description" option.

File

tests/taxonomy_menu.test, line 549
Defines abstract base test class for the Taxonomy menu module tests.

Class

TaxonomyMenuConfigurationTest
Tests Taxonomy menu configuration options.

Code

public function testTaxonomyMenuTermDescriptionOption() {
  $vocab = $this->vocabulary->machine_name;

  // Set settings on expanded.
  $edit = array(
    'taxonomy_menu[vocab_parent]' => 'main-menu:0',
    'taxonomy_menu[options_markup][term_item_description]' => FALSE,
    'taxonomy_menu[options_markup][display_title_attr]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $vocab . '/edit', $edit, t('Save'));

  // Assert that menu links does not have the term description.
  $term = $this->terms_hierarchy[3];
  $mlid = _taxonomy_menu_get_mlid($term->tid, $this->vocabulary->vid);
  $menu_link = menu_link_load($mlid);
  $menu_link_title = $menu_link['options']['attributes']['title'];
  $this
    ->assertEqual($menu_link_title, '');

  // Assert that menu links does have the term description, when the option is
  // checked.
  $edit = array(
    'taxonomy_menu[vocab_parent]' => 'main-menu:0',
    'taxonomy_menu[options_markup][term_item_description]' => TRUE,
    'taxonomy_menu[options_markup][display_title_attr]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $vocab . '/edit', $edit, t('Save'));
  $menu_link = menu_link_load($mlid);
  $menu_link_title = $menu_link['options']['attributes']['title'];
  $this
    ->assertEqual($menu_link_title, trim($term->description));

  // Assert that menu links does not have the term description, when the option
  // for displaying a description is on but the display title option is off.
  $edit = array(
    'taxonomy_menu[vocab_parent]' => 'main-menu:0',
    'taxonomy_menu[options_markup][term_item_description]' => TRUE,
    'taxonomy_menu[options_markup][display_title_attr]' => FALSE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $vocab . '/edit', $edit, t('Save'));
  $menu_link = menu_link_load($mlid);
  $menu_link_title = $menu_link['options']['attributes']['title'];
  $this
    ->assertEqual($menu_link_title, '');
}