You are here

protected function ContentTranslationLanguageChangeTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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() : void {
  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
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->submitForm($edit, '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
    ->submitForm($edit, 'Save and continue');
  $this
    ->submitForm([], 'Save field settings');
  $this
    ->submitForm([], 'Save settings');
}