You are here

public function LanguageConfigurationElementTest::testTaxonomyVocabularyUpdate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testTaxonomyVocabularyUpdate()
  2. 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 236

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\Tests\language\Functional

Code

public function testTaxonomyVocabularyUpdate() {
  $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
    ->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save'));

  // Check the language default configuration.
  $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country');
  $uuid = $configuration
    ->uuid();
  $this
    ->assertEqual($configuration
    ->getDefaultLangcode(), 'current_interface', '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
    ->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save'));

  // Check that we still have the settings for the updated vocabulary.
  $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country');
  $this
    ->assertEqual($configuration
    ->getDefaultLangcode(), 'current_interface', '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
    ->assertEqual($configuration
    ->uuid(), $uuid, 'The language configuration uuid has been kept on the updated Country vocabulary.');
}