You are here

protected function ContentTranslationLanguageChangeTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLanguageChangeTest::setUp()

Overrides NodeTestBase::setUp

File

core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php, line 43

Class

ContentTranslationLanguageChangeTest
Tests the content translation language that is set.

Namespace

Drupal\Tests\content_translation\Functional

Code

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

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

  // Add an image field.
  $this
    ->drupalGet('admin/structure/types/manage/article/fields/add-field');
  $edit = [
    'new_storage_type' => 'image',
    'field_name' => 'image_field',
    'label' => 'image_field',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save and continue'));
  $this
    ->drupalPostForm(NULL, [], t('Save field settings'));
  $this
    ->drupalPostForm(NULL, [], t('Save settings'));
}