Index: modules/taxonomy/taxonomy.test =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v retrieving revision 1.8 diff -u -p -r1.8 taxonomy.test --- modules/taxonomy/taxonomy.test 24 Sep 2008 18:42:00 -0000 1.8 +++ modules/taxonomy/taxonomy.test 9 Oct 2008 15:02:21 -0000 @@ -381,6 +381,114 @@ class TaxonomyAdminTestCase extends Drup } /** + * Changing weights on the vocabulary overview with two or more vocabularies. + */ + function testTaxonomyAdminChangingWeights() { + // Login as admin + $this->drupalLogin($this->taxonomy_admin); + + // Create taxonomies + for ($i = -10; $i <= 10; $i++) { + $edit = array( + 'name' => $this->randomName(), + 'nodes[article]' => 'article', + 'weight' => $i, + ); + $this->drupalPost('admin/content/taxonomy/add', $edit, t('Save')); + } + + // Getting the weights + $this->drupalGet('admin/content/taxonomy'); + $this->assertResponse('200'); + $vocabularies = taxonomy_get_vocabularies(); + + // Changing the weights + $edit = array(); + foreach ($vocabularies as $key => $voc) { + $voc->weight = -$voc->weight; + $vocabularies[$key]->weight = $voc->weight; + $edit[$key .'[weight]'] = $voc->weight; + } + // Saving the weights + $this->drupalPost('admin/content/taxonomy/', $edit, t('Save')); + + // Load the modified weights + $newvocabularies = taxonomy_get_vocabularies(); + + // Checking the modified weights + foreach ($vocabularies as $key => $voc) { + $this->assertEqual($newvocabularies[$key]->weight, $vocabularies[$key]->weight, t('The vocabulary weight was changed. ['. $key .' => '. $newvocabularies[$key]->weight .' == '. $vocabularies[$key]->weight)); + } + } + + /** + * Vocabulary overview with no vocabularies. + */ + function testTaxonomyAdminNoVocabularies() { + // Login as admin + $this->drupalLogin($this->taxonomy_admin); + + // Deleting the taxonomies + $this->drupalGet('admin/content/taxonomy'); + $this->assertResponse('200'); + $vocabularies = taxonomy_get_vocabularies(); + foreach ($vocabularies as $key => $voc) { + $vid = $voc->vid; + + // Delete the taxonomy + $edit = array(); + $this->drupalPost('admin/content/taxonomy/' .$vid, $edit, t('Delete')); + // Confirm deletion. + $this->drupalPost(NULL, NULL, t('Delete')); + } + + // Check no vocabularies + $this->assertText(t('No vocabularies available.'), t('Inform that no vocabularies.')); + } + + /** + * Deleting a vocabulary. + */ + function testTaxonomyAdminDeletingVocabulary() { + // Login as admin + $this->drupalLogin($this->taxonomy_admin); + + // Create a taxonomy + $this->drupalGet('admin/content/taxonomy'); + $this->assertResponse('200'); + $this->drupalGet('admin/content/taxonomy/add'); + $this->assertResponse('200'); + $edit = array( + 'name' => $this->randomName(), + 'nodes[article]' => 'article', + ); + $this->drupalPost('admin/content/taxonomy/add', $edit, t('Save')); + $this->assertResponse('200'); + $this->assertText(t('Created new vocabulary'), t('New vocabulary was created.')); + + // Check the created taxonomy + $vocabularies = taxonomy_get_vocabularies(); + $vid = $vocabularies[count($vocabularies)-1]->vid; + $vocabulary = taxonomy_vocabulary_load($vid, TRUE); + $this->assertTrue($vocabulary, t('Taxonomy found in database')); + $this->assertEqual($vocabulary->vid, $vid, t('Loaded taxonomy equal to getted taxonomy')); + + // Delete the taxonomy + $this->drupalGet('admin/content/taxonomy/'. $vid); + $this->assertResponse('200'); + $edit = array(); + $this->drupalPost('admin/content/taxonomy/' .$vid, $edit, t('Delete')); + $this->assertResponse('200'); + $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->name)), t('[confirm deletion] Asks for confirmation.')); + $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), t('[confirm deletion] Inform that all terms will be deleted.')); + + // Confirm deletion. + $this->drupalPost(NULL, NULL, t('Delete')); + $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->name)), t('Vocabulary deleted')); + $this->assertFalse(taxonomy_vocabulary_load($vid, TRUE), t('Taxonomy is not found in the database')); + } + + /** * Visit the various admin pages for the default 'Tags' vocabulary. */ function testTaxonomyAdminPages() {