function ForumTest::editForumVocabulary
Same name in other branches
- 9 core/modules/forum/tests/src/Functional/ForumTest.php \Drupal\Tests\forum\Functional\ForumTest::editForumVocabulary()
- 8.9.x core/modules/forum/tests/src/Functional/ForumTest.php \Drupal\Tests\forum\Functional\ForumTest::editForumVocabulary()
- 10 core/modules/forum/tests/src/Functional/ForumTest.php \Drupal\Tests\forum\Functional\ForumTest::editForumVocabulary()
Edits the forum taxonomy.
1 call to ForumTest::editForumVocabulary()
- ForumTest::doAdminTests in core/
modules/ forum/ tests/ src/ Functional/ ForumTest.php - Runs admin tests on the admin user.
File
-
core/
modules/ forum/ tests/ src/ Functional/ ForumTest.php, line 393
Class
- ForumTest
- Tests for forum.module.
Namespace
Drupal\Tests\forum\FunctionalCode
public function editForumVocabulary() {
// Backup forum taxonomy.
$vid = $this->config('forum.settings')
->get('vocabulary');
$original_vocabulary = Vocabulary::load($vid);
// Generate a random name and description.
$edit = [
'name' => $this->randomMachineName(10),
'description' => $this->randomMachineName(100),
];
// Edit the vocabulary.
$this->drupalGet('admin/structure/taxonomy/manage/' . $original_vocabulary->id());
$this->submitForm($edit, 'Save');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains("Updated vocabulary {$edit['name']}.");
// Grab the newly edited vocabulary.
$current_vocabulary = Vocabulary::load($vid);
// Make sure we actually edited the vocabulary properly.
$this->assertEquals($edit['name'], $current_vocabulary->label(), 'The name was updated');
$this->assertEquals($edit['description'], $current_vocabulary->getDescription(), 'The description was updated');
// Restore the original vocabulary's name and description.
$current_vocabulary->set('name', $original_vocabulary->label());
$current_vocabulary->set('description', $original_vocabulary->getDescription());
$current_vocabulary->save();
// Reload vocabulary to make sure changes are saved.
$current_vocabulary = Vocabulary::load($vid);
$this->assertEquals($original_vocabulary->label(), $current_vocabulary->label(), 'The original vocabulary settings were restored');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.