You are here

public function TaxonomyMenuConfigurationTest::testTaxonomyMenuFlattenOption in Taxonomy menu 7.2

Tests Taxonommy Menu "Flatten" option.

File

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

Class

TaxonomyMenuConfigurationTest
Tests Taxonomy menu configuration options.

Code

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

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

  // Assert that all of the menu links have no children with the root being
  // the menu.
  $query = db_select('menu_links', 'ml');
  $query
    ->join('taxonomy_menu', 'tm', 'ml.mlid = tm.mlid');
  $query
    ->fields('ml');
  $query
    ->condition('tm.vid', $this->vocabulary->vid)
    ->condition('ml.menu_name', 'main-menu')
    ->condition('ml.module', 'taxonomy_menu')
    ->condition('ml.has_children', 0)
    ->condition('ml.plid', 0);
  $row_count = $query
    ->execute()
    ->rowCount();
  $this
    ->assertEqual(count($this->terms_hierarchy), $row_count);

  // Assert that all of the menu links have no children with the root being
  // a menu item.
  $item = array(
    'menu_name' => 'main-menu',
    'weight' => 0,
    'link_title' => 'test',
    'link_path' => '<front>',
    'module' => 'taxonomy_menu',
  );
  $mlid = menu_link_save($item);
  menu_cache_clear('main-menu');
  $edit = array(
    'taxonomy_menu[vocab_parent]' => 'main-menu:' . $mlid,
    'taxonomy_menu[options_structure][flat]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $vocab . '/edit', $edit, t('Save'));
  $query = db_select('menu_links', 'ml');
  $query
    ->join('taxonomy_menu', 'tm', 'ml.mlid = tm.mlid');
  $query
    ->fields('ml');
  $query
    ->condition('tm.vid', $this->vocabulary->vid)
    ->condition('ml.menu_name', 'main-menu')
    ->condition('ml.module', 'taxonomy_menu')
    ->condition('ml.has_children', 0)
    ->condition('ml.plid', $mlid);
  $row_count = $query
    ->execute()
    ->rowCount();
  $this
    ->assertEqual(count($this->terms_hierarchy), $row_count);
}