You are here

function TermLanguageTest::testDefaultTermLanguage in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/src/Tests/TermLanguageTest.php \Drupal\taxonomy\Tests\TermLanguageTest::testDefaultTermLanguage()

File

core/modules/taxonomy/src/Tests/TermLanguageTest.php, line 81
Contains \Drupal\taxonomy\Tests\TermLanguageTest.

Class

TermLanguageTest
Tests the language functionality for the taxonomy terms.

Namespace

Drupal\taxonomy\Tests

Code

function testDefaultTermLanguage() {

  // Configure the vocabulary to not hide the language selector, and make the
  // default language of the terms fixed.
  $edit = array(
    'default_language[langcode]' => 'bb',
    'default_language[language_alterable]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id(), $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode-0-value', 'bb', 'The expected langcode was selected.');

  // Make the default language of the terms to be the current interface.
  $edit = array(
    'default_language[langcode]' => 'current_interface',
    'default_language[language_alterable]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id(), $edit, t('Save'));
  $this
    ->drupalGet('aa/admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode-0-value', 'aa', "The expected langcode, 'aa', was selected.");
  $this
    ->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode-0-value', 'bb', "The expected langcode, 'bb', was selected.");

  // Change the default language of the site and check if the default terms
  // language is still correctly selected.
  $this
    ->config('system.site')
    ->set('default_langcode', 'cc')
    ->save();
  $edit = array(
    'default_language[langcode]' => LanguageInterface::LANGCODE_SITE_DEFAULT,
    'default_language[language_alterable]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id(), $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode-0-value', 'cc', "The expected langcode, 'cc', was selected.");
}