You are here

public function LingotekNodeBulkCancelTest::testNodeCancelTarget in Lingotek Translation 3.7.x

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

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

File

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

Class

LingotekNodeBulkCancelTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeCancelTarget() {

  // 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
      ->getBulkOperationNameForCancelTarget('es', '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 target has been cancelled remotely.
  $cancelled_locales = \Drupal::state()
    ->get('lingotek.cancelled_locales', []);
  $this
    ->assertTrue(isset($cancelled_locales['dummy-document-hash-id']) && in_array('es_ES', $cancelled_locales['dummy-document-hash-id']), 'The document target has been cancelled remotely.');
  $entity = Node::load(1);
  $this
    ->assertEquals('dummy-document-hash-id', $content_translation_service
    ->getDocumentId($entity));
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
  $this
    ->assertIdentical(Lingotek::STATUS_CURRENT, $content_translation_service
    ->getSourceStatus($entity));
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $content_translation_service
    ->getTargetStatus($entity, 'es'));

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