function ContentTmgmtEntitySourceListTest::testTermBundleFilter in Translation Management Tool 8
Tests that the term bundle filter works.
File
- sources/
content/ tests/ src/ Functional/ ContentTmgmtEntitySourceListTest.php, line 62
Class
- ContentTmgmtEntitySourceListTest
- Tests the user interface for entity translation lists.
Namespace
Drupal\Tests\tmgmt_content\FunctionalCode
function testTermBundleFilter() {
$vocabulary1 = Vocabulary::create([
'vid' => 'vocab1',
'name' => $this
->randomMachineName(),
]);
$vocabulary1
->save();
$term1 = Term::create([
'name' => $this
->randomMachineName(),
'vid' => $vocabulary1
->id(),
]);
$term1
->save();
$vocabulary2 = Vocabulary::create([
'vid' => 'vocab2',
'name' => $this
->randomMachineName(),
]);
$vocabulary2
->save();
$term2 = Term::create([
'name' => $this
->randomMachineName(),
'vid' => $vocabulary2
->id(),
]);
$term2
->save();
$content_translation_manager = \Drupal::service('content_translation.manager');
$content_translation_manager
->setEnabled('taxonomy_term', $vocabulary1
->id(), TRUE);
$content_translation_manager
->setEnabled('taxonomy_term', $vocabulary2
->id(), TRUE);
$this
->drupalGet('admin/tmgmt/sources/content/taxonomy_term');
// Both terms should be displayed with their bundle.
$this
->assertSession()
->pageTextContains($term1
->label());
$this
->assertSession()
->pageTextContains($term2
->label());
$this
->assertNotEmpty($this
->xpath('//td[text()=@vocabulary]', array(
'@vocabulary' => $vocabulary1
->label(),
)));
$this
->assertNotEmpty($this
->xpath('//td[text()=@vocabulary]', array(
'@vocabulary' => $vocabulary2
->label(),
)));
// Limit to the first vocabulary.
$edit = array();
$edit['search[vid]'] = $vocabulary1
->id();
$this
->drupalPostForm(NULL, $edit, t('Search'));
// Only term 1 should be displayed now.
$this
->assertSession()
->pageTextContains($term1
->label());
$this
->assertNoText($term2
->label());
$this
->assertNotEmpty($this
->xpath('//td[text()=@vocabulary]', array(
'@vocabulary' => $vocabulary1
->label(),
)));
$this
->assertEmpty($this
->xpath('//td[text()=@vocabulary]', array(
'@vocabulary' => $vocabulary2
->label(),
)));
}