You are here

public function LingotekContentTypeBulkTranslationTest::testEditedConfigTranslationUsingLinksInAutomaticUploadMode in Lingotek Translation 3.6.x

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

Tests that a node can be translated using the links on the management page.

File

tests/src/Functional/LingotekContentTypeBulkTranslationTest.php, line 317

Class

LingotekContentTypeBulkTranslationTest
Tests translating a config entity using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testEditedConfigTranslationUsingLinksInAutomaticUploadMode() {
  $assert_session = $this
    ->assertSession();

  // We need a node with translations first.
  $this
    ->testContentTypeTranslationUsingLinks();

  // Set upload as automatic.
  $this
    ->saveLingotekConfigTranslationSettings([
    'node_type' => 'automatic',
  ]);

  // Add a language so we can check that it's not marked as dirty if there are
  // no translations.
  ConfigurableLanguage::createFromLangcode('eu')
    ->setThirdPartySetting('lingotek', 'locale', 'eu_ES')
    ->save();

  // Edit the object
  $this
    ->drupalPostForm('/admin/structure/types/manage/article', [
    'name' => 'Article EDITED',
  ], t('Save content type'));

  // Go to the bulk config management page.
  $this
    ->goToConfigBulkManagementForm('node_type');

  // The source status is 'Importing' because of automatic upload.
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);

  // Ensure it has the expected timestamp for updated and upload
  $timestamp = \Drupal::time()
    ->getRequestTime();
  foreach (LingotekConfigMetadata::loadMultiple() as $metadata) {
    $this
      ->assertEquals($timestamp, $metadata
      ->getLastUpdated());
    $this
      ->assertEquals($timestamp, $metadata
      ->getLastUploaded());
  }

  // Check the target statuses are not affected, but the current is back to pending.
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
  $this
    ->assertTargetStatus('EU', Lingotek::STATUS_REQUEST);

  // Recheck status.
  $this
    ->clickLink('EN');
  $this
    ->assertText('Article EDITED status checked successfully');

  // Check the translation after having been edited.
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckTranslations('node_type'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertText('Operations completed.');

  // Download the translation.
  $this
    ->clickLink('ES');
  $this
    ->assertText('Translation to es_MX downloaded successfully');
}