You are here

protected function LingotekTaxonomyTermTranslationTest::setUp in Lingotek Translation 3.0.x

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekTaxonomyTermTranslationTest.php, line 40

Class

LingotekTaxonomyTermTranslationTest
Tests translating a taxonomy term.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

  // Place the actions and title block.
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('page_title_block');

  // Create Article node types.
  $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('taxonomy_term', $this->vocabulary
    ->id())
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('taxonomy_term', $this->vocabulary
    ->id(), TRUE);
  $this
    ->applyEntityUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $bundle = $this->vocabulary
    ->id();
  $this
    ->saveLingotekContentTranslationSettings([
    'taxonomy_term' => [
      $bundle => [
        'profiles' => 'automatic',
        'fields' => [
          'name' => 1,
          'description' => 1,
        ],
      ],
    ],
  ]);

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'taxonomy_term');
}