You are here

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

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeNotificationCallbackQueueWorkerTest.php, line 35

Class

LingotekNodeNotificationCallbackQueueWorkerTest
Tests translating a node using the notification callback with a queue worker.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

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

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

  // 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();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', 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
    ->saveLingotekContentTranslationSettingsForNodeTypes();
  $profile = LingotekProfile::create([
    'id' => 'automatic_worker',
    'label' => 'Custom profile',
    'auto_upload' => TRUE,
    'auto_request' => TRUE,
    'auto_download' => TRUE,
    'auto_download_worker' => TRUE,
  ]);
  $profile
    ->save();
}