function TaxonomyVocabularyFunctionalTest::testTaxonomyAdminChangingWeights

Changing weights on the vocabulary overview with two or more vocabularies.

File

modules/taxonomy/taxonomy.test, line 120

Class

TaxonomyVocabularyFunctionalTest
Tests the taxonomy vocabulary interface.

Code

function testTaxonomyAdminChangingWeights() {
  // Create some vocabularies.
  for ($i = 0; $i < 10; $i++) {
    $this->createVocabulary();
  }
  // Get all vocabularies and change their weights.
  $vocabularies = taxonomy_get_vocabularies();
  $edit = array();
  foreach ($vocabularies as $key => $vocabulary) {
    $vocabulary->weight = -$vocabulary->weight;
    $vocabularies[$key]->weight = $vocabulary->weight;
    $edit[$key . '[weight]'] = $vocabulary->weight;
  }
  // Saving the new weights via the interface.
  $this->drupalPost('admin/structure/taxonomy', $edit, t('Save'));
  // Load the vocabularies from the database.
  $new_vocabularies = taxonomy_get_vocabularies();
  // Check that the weights are saved in the database correctly.
  foreach ($vocabularies as $key => $vocabulary) {
    $this->assertEqual($new_vocabularies[$key]->weight, $vocabularies[$key]->weight, 'The vocabulary weight was changed.');
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.