You are here

protected function LingotekNodeWithPathautoTranslationTest::setUp in Lingotek Translation 3.5.x

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeWithPathautoTranslationTest.php, line 33

Class

LingotekNodeWithPathautoTranslationTest
Tests translating a node that contains a path.

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
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add locales.
  ConfigurableLanguage::createFromLangcode('es-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();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);

  // Create pathauto config.
  $this
    ->createPattern('node', '/node/[node:title]')
    ->save();
  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
    ->saveLingotekContentTranslationSettings([
    'node' => [
      'article' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'body' => 1,
          'path' => 1,
        ],
      ],
    ],
  ]);
}