You are here

protected function LingotekActionsTest::setUp in Lingotek Translation 3.1.x

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/Actions/LingotekActionsTest.php, line 30

Class

LingotekActionsTest
Tests for Lingotek actions creation.

Namespace

Drupal\Tests\lingotek\Functional\Actions

Code

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

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

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $this->vocabulary
    ->id())
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  \Drupal::service('content_translation.manager')
    ->setEnabled('taxonomy_term', $this->vocabulary
    ->id(), 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();
}