ForumTestCase::editForumTaxonomy

7 forum.test ForumTestCase::editForumTaxonomy()
8 forum.test ForumTestCase::editForumTaxonomy()

Edit the forum taxonomy.

File

modules/forum/forum.test, line 275
Tests for forum.module.

Code

function editForumTaxonomy() {
  // Backup forum taxonomy.
  $vid = variable_get('forum_nav_vocabulary', '');
  $original_settings = taxonomy_vocabulary_load($vid);

  // Generate a random name/description.
  $title = $this->randomName(10);
  $description = $this->randomName(100);

  $edit = array(
    'name' => $title, 
    'description' => $description, 
    'machine_name' => drupal_strtolower(drupal_substr($this->randomName(), 3, 9)),
  );

  // Edit the vocabulary.
  $this->drupalPost('admin/structure/taxonomy/' . $original_settings->machine_name . '/edit', $edit, t('Save'));
  $this->assertResponse(200);
  $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), t('Vocabulary was edited'));

  // Grab the newly edited vocabulary.
  entity_get_controller('taxonomy_vocabulary')->resetCache();
  $current_settings = taxonomy_vocabulary_load($vid);

  // Make sure we actually edited the vocabulary properly.
  $this->assertEqual($current_settings->name, $title, t('The name was updated'));
  $this->assertEqual($current_settings->description, $description, t('The description was updated'));

  // Restore the original vocabulary.
  taxonomy_vocabulary_save($original_settings);
  drupal_static_reset('taxonomy_vocabulary_load');
  $current_settings = taxonomy_vocabulary_load($vid);
  $this->assertEqual($current_settings->name, $original_settings->name, 'The original vocabulary settings were restored');
}
Login or register to post comments