You are here

public function TaxonomyMenuFunctionalTest::testTaxonomyMenuVocabularyInterface in Taxonomy menu 8

Save, edit and delete a taxonomy vocabulary using the user interface.

File

lib/Drupal/taxonomy_menu/Tests/TaxonomyMenuFunctionalTest.php, line 44
Contains \Drupal\taxonomy_menu\Tests\TaxonomyMenuFunctionalTest.

Class

TaxonomyMenuFunctionalTest
Tests the taxonomy vocabulary interface.

Namespace

Drupal\taxonomy_menu\Tests

Code

public function testTaxonomyMenuVocabularyInterface() {
  $menu_name = 'account';
  $vid = $this->vocabulary
    ->id();

  // Visit the main taxonomy administration page.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $vid);

  // Options for the taxonomy vocabulary edit form.
  $edit = array();

  // Try to submit a vocabulary when menu location is a root menu item.
  $edit['taxonomy_menu[vocab_parent]'] = $menu_name . ':0';
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu has been created.'));

  // Try to re-submit a vocabulary when an option has changed.
  $edit['taxonomy_menu[options_structure][hide_empty_terms]'] = TRUE;
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu has been updated.'));

  // Try to re-submit a vocabulary without changing any option.
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu was not updated. Nothing to update.'));

  // Try to submit a vocabulary removing the menu location.
  $edit['taxonomy_menu[vocab_parent]'] = '0';
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu has been removed.'));
}