You are here

protected function LingotekSaveTargetDataTest::setUp in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  2. 3.0.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  3. 3.1.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  4. 3.2.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  5. 3.3.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  6. 3.4.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  7. 3.5.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  8. 3.6.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  9. 3.7.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()
  10. 3.8.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::setUp()

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekSaveTargetDataTest.php, line 25

Class

LingotekSaveTargetDataTest
Tests the Lingotek content service saves data to entities correctly.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Create Article node type.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add languages.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_ES')
    ->save();
  ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_DE')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  drupal_static_reset();
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();
  $this
    ->applyEntityUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $this
    ->saveLingotekContentTranslationSettingsForNodeTypes();
}