public function LingotekNodeBulkCancelTest::testNodeCancel in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 4.0.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.0.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.1.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.2.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.3.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.4.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.6.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 3.7.x tests/src/Functional/LingotekNodeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkCancelTest::testNodeCancel()
- 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\FunctionalCode
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();
}