You are here

public function LingotekNodeBulkTranslationTest::testNodeTranslationUsingActionsForMultipleLocalesAfterEditingWithPendingPhases in Lingotek Translation 8

File

src/Tests/LingotekNodeBulkTranslationTest.php, line 310

Class

LingotekNodeBulkTranslationTest
Tests translating a node using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testNodeTranslationUsingActionsForMultipleLocalesAfterEditingWithPendingPhases() {
  $this
    ->testNodeTranslationUsingActionsForMultipleLocales();

  // Edit the node.
  $edit = array();
  $edit['title[0][value]'] = 'Llamas are cool EDITED';
  $this
    ->drupalPostForm('node/1/edit', $edit, t('Save and keep published (this translation)'));
  $basepath = \Drupal::request()
    ->getBasePath();
  $this
    ->goToContentBulkManagementForm();

  // Let's upload the edited content so it's updated and downloadable.
  $this
    ->clickLink('EN');

  // Check the source status is current.
  $this
    ->clickLink('EN');

  // Ensure we won't get a completed document because there are phases pending.
  \Drupal::state()
    ->set('lingotek.document_completion', FALSE);

  // Check all statuses, after being edited and the source re-uploaded
  // Should be in STATUS_PENDING
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/entity/check_target/dummy-document-hash-id/de_AT?destination=' . $basepath . '/admin/lingotek/manage/node');
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/entity/check_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
  $edit = [
    'table[1]' => TRUE,
    // Node 1.
    'operation' => 'check_translations',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));

  // Ensure that the statuses are set to PENDING since the source has been
  // reuploaded and the targets are being translated. It is possible that
  // some of the translation is finished and could be downloaded, but that
  // should be marked as STATUS_READY_INTERIM but that has not been
  // implemented yet.
  // TODO: update test to check that status is STATUS_READY_INTERIM and then
  // they can be downloaded and then the status is set to STATUS_INTERMEDIATE
  // see ticket: https://www.drupal.org/node/2850548
  // Check the status is PENDING for Spanish and German.
  $de_edited = $this
    ->xpath("//a[contains(@class,'language-icon') and contains(@class,'target-pending')  and contains(text(), 'DE')]");
  $this
    ->assertEqual(count($de_edited), 1, 'German is marked as pending.');
  $es_edited = $this
    ->xpath("//a[contains(@class,'language-icon') and contains(@class,'target-pending')  and contains(text(), 'ES')]");
  $this
    ->assertEqual(count($es_edited), 1, 'Spanish is marked as pending.');
}