You are here

protected function LingotekNodeNestedParagraphsTranslationTest::setUp in Lingotek Translation 3.6.x

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

Overrides LingotekTestBase::setUp

1 call to LingotekNodeNestedParagraphsTranslationTest::setUp()
LingotekNodeNestedTranslatableParagraphsAsymmetricTranslationTest::setUp in tests/src/Functional/LingotekNodeNestedTranslatableParagraphsAsymmetricTranslationTest.php
1 method overrides LingotekNodeNestedParagraphsTranslationTest::setUp()
LingotekNodeNestedTranslatableParagraphsAsymmetricTranslationTest::setUp in tests/src/Functional/LingotekNodeNestedTranslatableParagraphsAsymmetricTranslationTest.php

File

tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php, line 34

Class

LingotekNodeNestedParagraphsTranslationTest
Tests translating a node with multiple locales including nested paragraphs.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

  // Place the actions and title block.
  $this
    ->drupalPlaceBlock('page_title_block', [
    'region' => 'content',
    'weight' => -5,
  ]);
  $this
    ->drupalPlaceBlock('local_tasks_block', [
    'region' => 'content',
    'weight' => -10,
  ]);

  // Add locales.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_ES')
    ->save();
  ConfigurableLanguage::createFromLangcode('es-ar')
    ->setThirdPartySetting('lingotek', 'locale', 'es_AR')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'paragraphed_nested_content')
    ->setLanguageAlterable(TRUE)
    ->save();
  ContentLanguageSettings::loadByEntityTypeBundle('paragraph', 'paragraph_container')
    ->setLanguageAlterable(TRUE)
    ->save();
  ContentLanguageSettings::loadByEntityTypeBundle('paragraph', 'image_text')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'paragraphed_nested_content', TRUE);
  \Drupal::service('content_translation.manager')
    ->setEnabled('paragraph', 'paragraph_container', TRUE);
  \Drupal::service('content_translation.manager')
    ->setEnabled('paragraph', 'image_text', 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();
  if ($this->paragraphsTranslatable) {
    $this
      ->setParagraphFieldsTranslatability();
  }
  $this
    ->saveLingotekContentTranslationSettings([
    'node' => [
      'paragraphed_nested_content' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'field_paragraph_container' => 1,
        ],
      ],
    ],
    'paragraph' => [
      'image_text' => [
        'fields' => [
          'field_image_demo' => [
            'title',
            'alt',
          ],
          'field_text_demo' => 1,
        ],
      ],
      'paragraph_container' => [
        'fields' => [
          'field_paragraphs_demo' => 1,
        ],
      ],
    ],
  ]);
  $this
    ->drupalGet('admin/lingotek/settings');

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