You are here

protected function MergeTranslationsFormTest::setUp in Merge translations 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/MergeTranslationsFormTest.php, line 44

Class

MergeTranslationsFormTest
Tests merge node translations.

Namespace

Drupal\Tests\merge_translations\Functional

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $this->editorUser = $this
    ->drupalCreateUser([
    'merge_permissions admin',
  ]);

  // Add several languages.
  ConfigurableLanguage::createFromLangcode('de')
    ->save();
  ConfigurableLanguage::createFromLangcode('es')
    ->save();
  ConfigurableLanguage::createFromLangcode('it')
    ->save();
  ConfigurableLanguage::createFromLangcode('pl')
    ->save();

  // Add several articles in different languages.
  $this->entities = [];
  foreach ([
    'en',
    'de',
    'es',
    'it',
    'pl',
  ] as $langcode) {
    $entity = Node::create([
      'title' => $this
        ->randomMachineName(),
      'type' => 'article',
      'langcode' => $langcode,
    ]);
    $entity
      ->save();
    $this->entities[$langcode] = $entity;
  }
  $this
    ->drupalLogin($this->editorUser);
}