function VocabularyLanguageTest::testVocabularyLanguage

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php \Drupal\Tests\taxonomy\Functional\VocabularyLanguageTest::testVocabularyLanguage()
  2. 10 core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php \Drupal\Tests\taxonomy\Functional\VocabularyLanguageTest::testVocabularyLanguage()
  3. 11.x core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php \Drupal\Tests\taxonomy\Functional\VocabularyLanguageTest::testVocabularyLanguage()

Tests language settings for vocabularies.

File

core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php, line 43

Class

VocabularyLanguageTest
Tests the language functionality for vocabularies.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testVocabularyLanguage() {
    $this->drupalGet('admin/structure/taxonomy/add');
    // Check that we have the language selector available.
    $this->assertField('edit-langcode', 'The language selector field was found on the page.');
    // Create the vocabulary.
    $vid = mb_strtolower($this->randomMachineName());
    $edit['name'] = $this->randomMachineName();
    $edit['description'] = $this->randomMachineName();
    $edit['langcode'] = 'aa';
    $edit['vid'] = $vid;
    $this->drupalPostForm(NULL, $edit, t('Save'));
    // Check the language on the edit page.
    $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
    $this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');
    // Change the language and save again.
    $edit['langcode'] = 'bb';
    unset($edit['vid']);
    $this->drupalPostForm(NULL, $edit, t('Save'));
    // Check again the language on the edit page.
    $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
    $this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');
}

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