function TermLanguageTest::testDefaultTermLanguage

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php \Drupal\Tests\taxonomy\Functional\TermLanguageTest::testDefaultTermLanguage()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php \Drupal\Tests\taxonomy\Functional\TermLanguageTest::testDefaultTermLanguage()
  3. 10 core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php \Drupal\Tests\taxonomy\Functional\TermLanguageTest::testDefaultTermLanguage()

File

core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php, line 93

Class

TermLanguageTest
Tests the language functionality for the taxonomy terms.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testDefaultTermLanguage() : void {
    // Configure the vocabulary to not hide the language selector, and make the
    // default language of the terms fixed.
    $edit = [
        'default_language[langcode]' => 'bb',
        'default_language[language_alterable]' => TRUE,
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id());
    $this->submitForm($edit, 'Save');
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/add');
    $this->assertTrue($this->assertSession()
        ->optionExists('edit-langcode-0-value', 'bb')
        ->isSelected());
    // Make the default language of the terms to be the current interface.
    $edit = [
        'default_language[langcode]' => 'current_interface',
        'default_language[language_alterable]' => TRUE,
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id());
    $this->submitForm($edit, 'Save');
    $this->drupalGet('aa/admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/add');
    $this->assertTrue($this->assertSession()
        ->optionExists('edit-langcode-0-value', 'aa')
        ->isSelected());
    $this->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/add');
    $this->assertTrue($this->assertSession()
        ->optionExists('edit-langcode-0-value', 'bb')
        ->isSelected());
    // Change the default language of the site and check if the default terms
    // language is still correctly selected.
    $this->config('system.site')
        ->set('default_langcode', 'cc')
        ->save();
    $edit = [
        'default_language[langcode]' => LanguageInterface::LANGCODE_SITE_DEFAULT,
        'default_language[language_alterable]' => TRUE,
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id());
    $this->submitForm($edit, 'Save');
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/add');
    $this->assertTrue($this->assertSession()
        ->optionExists('edit-langcode-0-value', 'cc')
        ->isSelected());
}

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