function LanguageConfigurationElementTest::testNodeTypeUpdate

Tests that the configuration is retained when the node type is updated.

File

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

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\Tests\language\Functional

Code

public function testNodeTypeUpdate() : void {
  // Create the article content type first if the profile used is not the
  // standard one.
  if ($this->profile != 'standard') {
    $this->drupalCreateContentType([
      'type' => 'article',
      'name' => 'Article',
    ]);
  }
  $admin_user = $this->drupalCreateUser([
    'administer content types',
  ]);
  $this->drupalLogin($admin_user);
  $edit = [
    'language_configuration[langcode]' => 'current_interface',
    'language_configuration[language_alterable]' => TRUE,
  ];
  $this->drupalGet('admin/structure/types/manage/article');
  $this->submitForm($edit, 'Save');
  // Check the language default configuration for the articles.
  $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article');
  $uuid = $configuration->uuid();
  $this->assertEquals('current_interface', $configuration->getDefaultLangcode(), 'The default language configuration has been saved on the Article content type.');
  $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Article content type.');
  // Update the article content type by changing the title label.
  $edit = [
    'title_label' => 'Name',
  ];
  $this->drupalGet('admin/structure/types/manage/article');
  $this->submitForm($edit, 'Save');
  // Check that we still have the settings for the updated node type.
  $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article');
  $this->assertEquals('current_interface', $configuration->getDefaultLangcode(), 'The default language configuration has been kept on the updated Article content type.');
  $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been kept on the updated Article content type.');
  $this->assertEquals($uuid, $configuration->uuid(), 'The language configuration uuid has been kept on the updated Article content type.');
}

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