public function HierarchicalTaxonomyMenuTranslationTest::testTranslatedBlockContentWithDisabledChild in Hierarchical Taxonomy Menu 8
Test translated terms status.
File
- tests/
src/ Functional/ HierarchicalTaxonomyMenuTranslationTest.php, line 116
Class
- HierarchicalTaxonomyMenuTranslationTest
- Tests the Hierarchical Taxonomy Menu block with translated taxonomy terms.
Namespace
Drupal\Tests\hierarchical_taxonomy_menu\FunctionalCode
public function testTranslatedBlockContentWithDisabledChild() {
$this
->drupalGet('taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringContainsString('Parent', $block_element
->getText());
$this
->assertStringContainsString('Child', $block_element
->getText());
$parent_term = Term::load(1);
$parent_term->status = FALSE;
$parent_term
->save();
$this
->drupalGet('taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringNotContainsString('Parent', $block_element
->getText());
$child_term = Term::load(2);
$child_term->status = FALSE;
$child_term
->save();
$this
->drupalGet('taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringNotContainsString('Child', $block_element
->getText());
$this
->drupalGet('sr/taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringContainsString('Roditelj', $block_element
->getText());
$this
->assertStringContainsString('Dete', $block_element
->getText());
$parent_term = Term::load(1);
$parent_term_sr = \Drupal::service('entity.repository')
->getTranslationFromContext($parent_term, 'sr');
$parent_term_sr->status = FALSE;
$parent_term_sr
->save();
$this
->drupalGet('sr/taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringNotContainsString('Roditelj', $block_element
->getText());
$child_term = Term::load(2);
$child_term_sr = \Drupal::service('entity.repository')
->getTranslationFromContext($child_term, 'sr');
$child_term_sr->status = FALSE;
$child_term_sr
->save();
$this
->drupalGet('sr/taxonomy/term/1');
$block_element = $this
->getSession()
->getPage()
->find('css', '.block-taxonomymenu__menu');
$this
->assertStringNotContainsString('Dete', $block_element
->getText());
}