function LanguageConfigurationElementTest::testTaxonomyVocabularyUpdate

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

Tests that the configuration is retained when a vocabulary is updated.

File

core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php, line 248

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\Tests\language\Functional

Code

public function testTaxonomyVocabularyUpdate() : void {
    $vocabulary = Vocabulary::create([
        'name' => 'Country',
        'vid' => 'country',
    ]);
    $vocabulary->save();
    $admin_user = $this->drupalCreateUser([
        'administer taxonomy',
    ]);
    $this->drupalLogin($admin_user);
    $edit = [
        'default_language[langcode]' => 'current_interface',
        'default_language[language_alterable]' => TRUE,
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/country');
    $this->submitForm($edit, 'Save');
    // Check the language default configuration.
    $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country');
    $uuid = $configuration->uuid();
    $this->assertEquals('current_interface', $configuration->getDefaultLangcode(), 'The default language configuration has been saved on the Country vocabulary.');
    $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Country vocabulary.');
    // Update the vocabulary.
    $edit = [
        'name' => 'Nation',
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/country');
    $this->submitForm($edit, 'Save');
    // Check that we still have the settings for the updated vocabulary.
    $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country');
    $this->assertEquals('current_interface', $configuration->getDefaultLangcode(), 'The default language configuration has been kept on the updated Country vocabulary.');
    $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been kept on the updated Country vocabulary.');
    $this->assertEquals($uuid, $configuration->uuid(), 'The language configuration uuid has been kept on the updated Country vocabulary.');
}

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