You are here

public function TaxonomyMenuConfigurationTest::testTaxonomyMenuExpandedOption in Taxonomy menu 7.2

Tests Taxonommy Menu expand option.

File

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

Class

TaxonomyMenuConfigurationTest
Tests Taxonomy menu configuration options.

Code

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

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

  // Build the base query.
  $base_query = db_select('menu_links', 'ml');
  $base_query
    ->join('taxonomy_menu', 'tm', 'ml.mlid = tm.mlid');
  $base_query
    ->fields('ml')
    ->condition('tm.vid', $this->vocabulary->vid)
    ->condition('ml.module', 'taxonomy_menu');

  // Assert that menu links are expanded.
  $query = $base_query
    ->condition('ml.expanded', TRUE);
  $row_count = $query
    ->execute()
    ->rowCount();
  $this
    ->assertEqual(count($this->terms_hierarchy), $row_count);

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

  // Assert that menu links are not expanded anymore.
  $query = $base_query
    ->condition('ml.expanded', FALSE);
  $row_count = $query
    ->execute()
    ->rowCount();
  $this
    ->assertEqual(0, $row_count);
}