You are here

protected function MenuMultilingualTest::setUp in Menu Multilingual 8

Overrides BrowserTestBase::setUp

1 call to MenuMultilingualTest::setUp()
MenuMultilingualMenuBlockTest::setUp in tests/src/Functional/MenuMultilingualMenuBlockTest.php
1 method overrides MenuMultilingualTest::setUp()
MenuMultilingualMenuBlockTest::setUp in tests/src/Functional/MenuMultilingualMenuBlockTest.php

File

tests/src/Functional/MenuMultilingualTest.php, line 52

Class

MenuMultilingualTest
Class MenuMultilingualTest.

Namespace

Drupal\Tests\menu_multilingual\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->drupalLogin($this->rootUser);

  // Place the main menu to the page.
  $this
    ->drupalPlaceBlock('system_menu_block:main', [
    'id' => 'stark_main_menu',
  ]);

  // Create an article content type.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);

  // Add FR language.
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();

  // Set prefixes to en and fr.
  $this
    ->drupalGet('admin/config/regional/language/detection/url');
  $this
    ->submitForm([
    'prefix[en]' => 'en',
    'prefix[fr]' => 'fr',
  ], 'Save configuration');

  // Set up URL language negotiation.
  $this
    ->drupalGet('admin/config/regional/language/detection');
  $this
    ->submitForm([
    'language_interface[enabled][language-url]' => 1,
  ], 'Save settings');
  $this
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->submitForm([
    "entity_types[node]" => 1,
    "settings[node][article][translatable]" => 1,
    "settings[node][article][settings][language][language_alterable]" => 1,
    "entity_types[menu_link_content]" => 1,
    "settings[menu_link_content][menu_link_content][translatable]" => 1,
    "settings[menu_link_content][menu_link_content][settings][language][language_alterable]" => 1,
  ], 'Save configuration');
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();

  // Create a translated node.
  $edit = [
    'title[0][value]' => 'Node 1 translated English',
    'langcode[0][value]' => 'en',
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Save');
  $edit = [
    'title[0][value]' => 'Node 1 translated French',
  ];
  $this
    ->drupalGet('node/1/translations/add/en/fr');
  $this
    ->submitForm($edit, 'Save');

  // Create an untranslated node.
  $edit = [
    'title[0][value]' => 'Node 2 untranslated English',
    'langcode[0][value]' => 'en',
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Save');

  // Create two language neutral nodes.
  $edit = [
    'title[0][value]' => 'Node 3 Language Not Applicable',
    'langcode[0][value]' => 'zxx',
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Save');
  $edit = [
    'title[0][value]' => 'Node 4 Language Not Specified',
    'langcode[0][value]' => 'und',
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Save');
}