You are here

public function TaxonomyMenuConfigurationTest::testTaxonomyMenuTermDescriptionOption in Taxonomy menu 8

Tests Taxonommy Menu "Term description" option.

File

lib/Drupal/taxonomy_menu/Tests/TaxonomyMenuConfigurationTest.php, line 116
Contains \Drupal\taxonomy_menu\Tests\TaxonomyMenuConfigurationTest.

Class

TaxonomyMenuConfigurationTest
Tests Taxonomy menu configuration options.

Namespace

Drupal\taxonomy_menu\Tests

Code

public function testTaxonomyMenuTermDescriptionOption() {
  $vid = $this->vocabulary
    ->id();

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

  // Assert that menu links does not have the term description.
  $term = $this->terms_hierarchy[3];
  $mlid = _taxonomy_menu_get_mlid($term
    ->id(), $this->vocabulary
    ->id());
  $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:0',
    'taxonomy_menu[options_markup][term_item_description]' => TRUE,
    'taxonomy_menu[options_markup][display_title_attr]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
  $menu_link = menu_link_load($mlid);
  $menu_link_title = $menu_link['options']['attributes']['title'];
  $this
    ->assertEqual($menu_link_title, trim($term
    ->getDescription()));

  // 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:0',
    'taxonomy_menu[options_markup][term_item_description]' => TRUE,
    'taxonomy_menu[options_markup][display_title_attr]' => FALSE,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
  $menu_link = menu_link_load($mlid);
  $menu_link_title = $menu_link['options']['attributes']['title'];
  $this
    ->assertEqual($menu_link_title, '');
}