You are here

protected function ContentTranslationJobsViewTest::setUp in Translation Views 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/ContentTranslationJobsViewTest.php, line 32

Class

ContentTranslationJobsViewTest
Tests for fields, filters and sorting (Content translation jobs view).

Namespace

Drupal\Tests\translation_views\Functional

Code

protected function setUp() {
  parent::setUp();
  $langcodes = [
    'de',
    'fr',
  ];
  foreach ($langcodes as $langcode) {
    ConfigurableLanguage::createFromLangcode($langcode)
      ->save();
  }
  $user = $this
    ->drupalCreateUser([
    'administer site configuration',
    'administer nodes',
    'create article content',
    'access content',
    'edit any article content',
    'administer content translation',
    'translate any entity',
    'create content translations',
    'administer languages',
    'administer content types',
  ]);
  $this
    ->drupalLogin($user);

  // Enable translation for article.
  $edit = [
    'entity_types[node]' => 1,
    'settings[node][article][translatable]' => 1,
    'settings[node][article][settings][language][language_alterable]' => 1,
  ];
  $this
    ->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();

  // Create node1 in german.
  $edit = [
    'title[0][value]' => 'node1 de',
    'langcode[0][value]' => 'de',
  ];
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save'));

  // Create node1 translation in french.
  $edit = [
    'title[0][value]' => 'node1 fr',
  ];
  $this
    ->drupalPostForm('node/1/translations/add/de/fr', $edit, t('Save (this translation)'));

  // Create node2 in english.
  $edit = [
    'title[0][value]' => 'node2 en',
    'langcode[0][value]' => 'en',
  ];
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save'));

  // Create node3 in french.
  $edit = [
    'title[0][value]' => 'node3 fr',
    'langcode[0][value]' => 'fr',
  ];
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save'));
}