You are here

public function LingotekNodeBulkCancelTest::testNodeCancel in Lingotek Translation 3.3.x

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

Tests that a node can be cancelled using the actions on the management page.

File

tests/src/Functional/LingotekNodeBulkCancelTest.php, line 54

Class

LingotekNodeBulkCancelTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeCancel() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Create a node.
  $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]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $this
    ->createAndTranslateNodeWithLinks();
  $this
    ->goToContentBulkManagementForm();

  // Mark the first for cancelling.
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCancel('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $content_translation_service */
  $content_translation_service = \Drupal::service('lingotek.content_translation');

  // Assert that The document has been cancelled remotely.
  $cancelled_docs = \Drupal::state()
    ->get('lingotek.cancelled_docs', []);
  $this
    ->assertEqual(1, count($cancelled_docs), 'The document has been cancelled remotely.');

  // Assert that no document has been deleted remotely.
  $deleted_docs = \Drupal::state()
    ->get('lingotek.deleted_docs', []);
  $this
    ->assertEqual(0, count($deleted_docs), 'No document has been deleted remotely.');
  $node = Node::load(1);
  $this
    ->assertNull($content_translation_service
    ->getDocumentId($node));
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $content_translation_service
    ->getSourceStatus($node));
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $content_translation_service
    ->getTargetStatus($node, 'es'));

  // We can request again.
  $this
    ->assertLingotekUploadLink();
  $this
    ->assertNoLingotekRequestTranslationLink('es_ES');
  $this
    ->createAndTranslateNodeWithLinks();
}