function VocabularyLanguageTest::testVocabularyLanguage

Tests language settings for vocabularies.

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php, line 51
Definition of Drupal\taxonomy\Tests\VocabularyLanguageTest.

Class

VocabularyLanguageTest
Tests for the language feature on vocabularies.

Namespace

Drupal\taxonomy\Tests

Code

function testVocabularyLanguage() {
  $this
    ->drupalGet('admin/structure/taxonomy/add');

  // Check that we have the language selector available.
  $this
    ->assertField('edit-langcode', 'The language selector field was found on the page');

  // Create the vocabulary.
  $vid = drupal_strtolower($this
    ->randomName());
  $edit['name'] = $this
    ->randomName();
  $edit['description'] = $this
    ->randomName();
  $edit['langcode'] = 'aa';
  $edit['vid'] = $vid;
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Check the language on the edit page.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $vid . '/edit');
  $this
    ->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');

  // Change the language and save again.
  $edit['langcode'] = 'bb';
  unset($edit['vid']);
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Check again the language on the edit page.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $vid . '/edit');
  $this
    ->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');
}