You are here

function EditForumTaxonomyTest::testEditForumTaxonomy in SimpleTest 6

File

tests/forum_module.test, line 122

Class

EditForumTaxonomyTest

Code

function testEditForumTaxonomy() {

  // Attempt to edit the forum taxonomy
  $web_user = $this
    ->drupalCreateUserRolePerm(array(
    'access administration pages',
    'administer taxonomy',
  ));
  $this
    ->drupalLoginUser($web_user);
  $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,
    'help' => '',
    'weight' => -10,
  );

  // Double check that the page says it has edited the vocabulary
  $this
    ->drupalPost('admin/content/taxonomy/edit/vocabulary/' . $vid, $edit, 'Save');
  $this
    ->assertWantedRaw(t('Updated vocabulary %name.', array(
    '%name' => $title,
  )), t('Vocabulary has been edited'));

  // Grab the newly edited vocabulary
  $cur_settings = db_fetch_array(db_query('SELECT v.* FROM {vocabulary} v WHERE v.vid = %d', $vid));

  // Make sure we actually edited the vocabulary properly
  $this
    ->assertTrue($cur_settings['name'] == $title, 'The name has been updated properly');
  $this
    ->assertTrue($cur_settings['description'] == $description, 'The description has been updated properly');

  // Restore the original settings
  $original_settings = (array) $original_settings;
  taxonomy_save_vocabulary($original_settings);
}