You are here

public function TaxonomyMenuFunctionalTest::testTaxonomyMenuTermInterface in Taxonomy menu 7.2

Saves, edits and deletes a term using the user interface.

File

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

Class

TaxonomyMenuFunctionalTest
Tests the taxonomy vocabulary interface.

Code

public function testTaxonomyMenuTermInterface() {
  $menu_name = 'main-menu';

  // Create a taxonomy menu.
  $vocab_settings['taxonomy_menu[vocab_parent]'] = $menu_name . ':0';
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $vocab_settings, t('Save'));

  // Create a new term from the interface.
  $term_settings = array(
    'name' => $this
      ->randomName(12),
    'description[value]' => $this
      ->randomName(100),
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $term_settings, t('Save'));
  $terms = taxonomy_get_term_by_name($term_settings['name']);
  $term = reset($terms);
  $this
    ->assertRaw(t('Added term %term to taxonomy menu %menu_name.', array(
    '%term' => $term_settings['name'],
    '%menu_name' => $menu_name,
  )));

  // Update an existing term from the interface.
  $new_term_settings = array(
    'name' => $this
      ->randomName(12),
    'description[value]' => $this
      ->randomName(100),
  );
  $this
    ->drupalPost('taxonomy/term/' . $term->tid . '/edit', $new_term_settings, t('Save'));
  $this
    ->assertRaw(t('Updated term %term in taxonomy menu %menu_name.', array(
    '%term' => $new_term_settings['name'],
    '%menu_name' => $menu_name,
  )));

  // Delete an existing term from the interface.
  $this
    ->drupalPost('taxonomy/term/' . $term->tid . '/edit', NULL, t('Delete'));
  $this
    ->drupalPost(NULL, NULL, t('Delete'));

  // Confirm deletion of term.
  $this
    ->assertRaw(t('Deleted term %term from taxonomy menu %menu_name.', array(
    '%term' => $new_term_settings['name'],
    '%menu_name' => $menu_name,
  )));
}