public function LanguageConfigurationElementTest::testNodeTypeUpdate

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

File

drupal/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php, line 115
Definition of Drupal\language\Tests\LanguageConfigurationElementTest.

Class

LanguageConfigurationElementTest
Functional tests for language configuration's effect on negotiation setup.

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_hidden]' => FALSE,
  );
  $this
    ->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));

  // Check the language default configuration for the articles.
  $configuration = language_get_default_configuration('node', 'article');
  $this
    ->assertEqual($configuration, array(
    'langcode' => 'current_interface',
    'language_hidden' => 0,
  ), 'The default language configuration has been saved on the Article content type.');

  // Rename the article content type.
  $edit = array(
    'type' => 'article_2',
  );
  $this
    ->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));

  // Check that we still have the settings for the new node type.
  $configuration = language_get_default_configuration('node', 'article_2');
  $this
    ->assertEqual($configuration, array(
    'langcode' => 'current_interface',
    'language_hidden' => 0,
  ), 'The default language configuration has been kept on the new Article content type.');
}