function TaxonomyVocabularyFunctionalTest::testTaxonomyAdminChangingWeights in Drupal 7
Changing weights on the vocabulary overview with two or more vocabularies.
File
- modules/
taxonomy/ taxonomy.test, line 118 - Tests for taxonomy.module.
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.');
}
}