You are here

public function LanguageConfigurationElementTest::testNodeTypeUpdate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/language/src/Tests/LanguageConfigurationElementTest.php \Drupal\language\Tests\LanguageConfigurationElementTest::testNodeTypeUpdate()

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

File

core/modules/language/src/Tests/LanguageConfigurationElementTest.php, line 157
Contains \Drupal\language\Tests\LanguageConfigurationElementTest.

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\language\Tests

Code

public function testNodeTypeUpdate() {

  // Create the article content type first if the profile used is not the
  // standard one.
  if ($this->profile != 'standard') {
    $this
      ->drupalCreateContentType(array(
      'type' => 'article',
      'name' => 'Article',
    ));
  }
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer content types',
  ));
  $this
    ->drupalLogin($admin_user);
  $edit = array(
    'language_configuration[langcode]' => 'current_interface',
    'language_configuration[language_alterable]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));

  // Check the language default configuration for the articles.
  $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article');
  $uuid = $configuration
    ->uuid();
  $this
    ->assertEqual($configuration
    ->getDefaultLangcode(), 'current_interface', '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 = array(
    'title_label' => 'Name',
  );
  $this
    ->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));

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