function TermLanguageTest::testTermLanguage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Tests/TermLanguageTest.php \Drupal\taxonomy\Tests\TermLanguageTest::testTermLanguage()
File
- core/modules/taxonomy/src/Tests/TermLanguageTest.php, line 47
- Contains \Drupal\taxonomy\Tests\TermLanguageTest.
Class
- TermLanguageTest
- Tests the language functionality for the taxonomy terms.
Namespace
Drupal\taxonomy\Tests
Code
function testTermLanguage() {
$edit = array(
'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
->assertField('edit-langcode-0-value', t('The language selector field was found on the page.'));
$edit = array(
'name[0][value]' => $this
->randomMachineName(),
'langcode[0][value]' => 'aa',
);
$this
->drupalPostForm(NULL, $edit, t('Save'));
$terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
$term = reset($terms);
$this
->assertEqual($term
->language()
->getId(), $edit['langcode[0][value]'], 'The term contains the correct langcode.');
$this
->drupalGet('taxonomy/term/' . $term
->id() . '/edit');
$this
->assertOptionSelected('edit-langcode-0-value', $edit['langcode[0][value]'], 'The term language was correctly selected.');
$edit['langcode[0][value]'] = 'bb';
$this
->drupalPostForm('taxonomy/term/' . $term
->id() . '/edit', $edit, t('Save'));
$this
->drupalGet('taxonomy/term/' . $term
->id() . '/edit');
$this
->assertOptionSelected('edit-langcode-0-value', $edit['langcode[0][value]'], 'The term language was correctly selected.');
}