You are here

public function LingotekContentModerationTest::testDownloadFromNotUploadStateDoesntTriggerATransition in Lingotek Translation 3.6.x

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

File

tests/src/Functional/LingotekContentModerationTest.php, line 418

Class

LingotekContentModerationTest
Tests setting up the integration with content moderation.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testDownloadFromNotUploadStateDoesntTriggerATransition() {

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'node+revision');
  $this
    ->configureNeedsReviewAsUploadState();
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'automatic';
  $this
    ->saveAsNewDraftNodeForm($edit, 'article');

  // The status is draft.
  $value = $this
    ->xpath('//div[@id="edit-current"]/text()');
  $value = trim($value[1]
    ->getText());
  $this
    ->assertEqual($value, 'Draft', 'Workbench current status is draft');

  // Moderate to Needs review, so it's uploaded.
  $edit = [
    'new_state' => 'needs_review',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Apply');

  // Moderate back to draft, so the transition won't happen on download.
  $edit = [
    'new_state' => 'draft',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Apply');
  $this
    ->goToContentBulkManagementForm();

  // Request translation.
  $this
    ->clickLink('ES');

  // Check translation.
  $this
    ->clickLink('ES');

  // Download translation.
  $this
    ->clickLink('ES');

  // Let's see the current status is unmodified.
  $this
    ->clickLink('Llamas are cool');
  $value = $this
    ->xpath('//div[@id="edit-current"]/text()');
  $value = trim($value[1]
    ->getText());
  $this
    ->assertEqual($value, 'Draft', 'The transition to a new content moderation status didn\'t happen because the source wasn\'t the expected.');
}