function LanguageConfigurationElementTest::testTaxonomyVocabularyUpdate
Tests that the configuration is retained when a vocabulary is updated.
File
- 
              core/
modules/ language/ tests/ src/ Functional/ LanguageConfigurationElementTest.php, line 251  
Class
- LanguageConfigurationElementTest
 - Tests the features of the language configuration element field.
 
Namespace
Drupal\Tests\language\FunctionalCode
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.