function TermLanguageTest::testDefaultTermLanguage

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php, line 81
Definition of Drupal\taxonomy\Tests\TermLanguageTest.

Class

TermLanguageTest
Tests for the language feature on 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_show]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/edit', $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode', 'bb');

  // Make the default language of the terms to be the current interface.
  $edit = array(
    'default_language[langcode]' => 'current_interface',
    'default_language[language_show]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/edit', $edit, t('Save'));
  $this
    ->drupalGet('aa/admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode', 'aa');
  $this
    ->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode', 'bb');

  // Change the default language of the site and check if the default terms
  // language is still correctly selected.
  $old_default = language_default();
  $old_default->default = FALSE;
  language_save($old_default);
  $new_default = language_load('cc');
  $new_default->default = TRUE;
  language_save($new_default);
  $edit = array(
    'default_language[langcode]' => 'site_default',
    'default_language[language_show]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/edit', $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/add');
  $this
    ->assertOptionSelected('edit-langcode', 'cc');
}