| 7 taxonomy.test | TaxonomyVocabularyFunctionalTest::testVocabularyInterface() |
| 8 taxonomy.test | TaxonomyVocabularyFunctionalTest::testVocabularyInterface() |
Create, edit and delete a vocabulary via the user interface.
File
- modules/
taxonomy/ taxonomy.test, line 67 - Tests for taxonomy.module.
Code
function testVocabularyInterface() {
// Visit the main taxonomy administration page.
$this->drupalGet('admin/structure/taxonomy');
// Create a new vocabulary.
$this->clickLink(t('Add vocabulary'));
$edit = array();
$machine_name = drupal_strtolower($this->randomName());
$edit['name'] = $this->randomName();
$edit['description'] = $this->randomName();
$edit['machine_name'] = $machine_name;
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('Created new vocabulary %name.', array('%name' => $edit['name'])), t('Vocabulary created successfully'));
// Edit the vocabulary.
$this->drupalGet('admin/structure/taxonomy');
$this->assertText($edit['name'], t('Vocabulary found in the vocabulary overview listing.'));
$this->clickLink(t('edit vocabulary'));
$edit = array();
$edit['name'] = $this->randomName();
$this->drupalPost(NULL, $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy');
$this->assertText($edit['name'], t('Vocabulary found in the vocabulary overview listing.'));
// Try to submit a vocabulary with a duplicate machine name.
$edit['machine_name'] = $machine_name;
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'));
// Try to submit an invalid machine name.
$edit['machine_name'] = '!&^%';
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this->assertText(t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
Login or register to post comments