You are here

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

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeEmbeddingBricksTranslationTest.php, line 48

Class

LingotekNodeEmbeddingBricksTranslationTest
Tests translating a node with multiple locales embedding another entity.

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,
  ]);
  $this
    ->drupalPlaceBlock('local_actions_block', [
    'region' => 'content',
    'weight' => -12,
  ]);

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

  // 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', '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();
  $this
    ->drupalGet('/admin/config/regional/content-language');
  $edit = [
    'settings[node][article][fields][field_brick]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $bundle = $this->vocabulary
    ->id();
  $this
    ->saveLingotekContentTranslationSettings([
    'node' => [
      'article' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'body' => 1,
          'field_brick' => 1,
        ],
      ],
    ],
    'taxonomy_term' => [
      $bundle => [
        'profiles' => 'manual',
        'fields' => [
          'name' => 1,
          'description' => 1,
        ],
      ],
    ],
  ]);

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