You are here

protected function HierarchicalTaxonomyMenuTranslationTest::setUp in Hierarchical Taxonomy Menu 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/HierarchicalTaxonomyMenuTranslationTest.php, line 42

Class

HierarchicalTaxonomyMenuTranslationTest
Tests the Hierarchical Taxonomy Menu block with translated taxonomy terms.

Namespace

Drupal\Tests\hierarchical_taxonomy_menu\Functional

Code

protected function setUp() {
  parent::setUp();
  $language = ConfigurableLanguage::createFromLangcode('sr');
  $language
    ->save();
  $admin_user = $this
    ->drupalCreateUser([
    'administer blocks',
    'administer site configuration',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($admin_user);
  $vocabulary = $this
    ->createVocabulary();
  $parent_term = $this
    ->createTerm($vocabulary, [
    'name' => 'Parent',
    'langcode' => 'en',
    'status' => TRUE,
  ]);
  $child_term = $this
    ->createTerm($vocabulary, [
    'name' => 'Child',
    'langcode' => 'en',
    'status' => TRUE,
  ]);
  $child_term->parent = $parent_term
    ->id();
  $child_term
    ->save();
  $parent_term_sr = $parent_term
    ->addTranslation('sr');
  $parent_term_sr->name = 'Roditelj';
  $parent_term_sr->langcode = 'sr';
  $parent_term_sr->status = TRUE;
  $parent_term_sr
    ->save();
  $child_term_sr = $child_term
    ->addTranslation('sr');
  $child_term_sr->name = 'Dete';
  $child_term_sr->langcode = 'sr';
  $child_term_sr->status = TRUE;
  $child_term_sr
    ->save();
  $block = $this
    ->drupalPlaceBlock('hierarchical_taxonomy_menu', [
    'region' => 'content',
    'label' => 'Hierarchical Taxonomy Menu',
    'id' => 'hierarchicaltaxonomymenu',
  ]);
  $block
    ->set('settings', [
    'label' => 'Hierarchical Taxonomy Menu',
    'label_display' => 'visible',
    'vocabulary' => $vocabulary
      ->id() . '|',
    'dynamic_block_title' => TRUE,
  ]);
  $block
    ->save();
}