public function LingotekFieldBodyBulkCancelTest::testFieldCancelTargetAlreadyCompleted in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekFieldBodyBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkCancelTest::testFieldCancelTargetAlreadyCompleted()
- 3.8.x tests/src/Functional/LingotekFieldBodyBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkCancelTest::testFieldCancelTargetAlreadyCompleted()
Tests that a field config target can be cancelled using the bulk operations on the management page.
File
- tests/
src/ Functional/ LingotekFieldBodyBulkCancelTest.php, line 141
Class
- LingotekFieldBodyBulkCancelTest
- Tests cancelling a field using the bulk management form.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testFieldCancelTargetAlreadyCompleted() {
$assert_session = $this
->assertSession();
\Drupal::state()
->set('lingotek.cancel_target_already_completed', TRUE);
// Login as admin.
$this
->drupalLogin($this->rootUser);
$this
->createAndTranslateFieldWithLinks();
// Mark the first for cancelling.
$edit = [
'table[node.article.body]' => 'node.article.body',
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancelTarget('es', 'node_fields'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
/** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
$config_translation_service = \Drupal::service('lingotek.config_translation');
\Drupal::entityTypeManager()
->getStorage('field_config')
->resetCache();
$entity = \Drupal::entityTypeManager()
->getStorage('field_config')
->load('node.article.body');
// Assert that the document target has been cancelled remotely.
$cancelled_locales = \Drupal::state()
->get('lingotek.cancelled_locales', []);
$this
->assertFalse(isset($cancelled_locales['dummy-document-hash-id']) && in_array('es_ES', $cancelled_locales['dummy-document-hash-id']), 'The document target has been cancelled remotely.');
$this
->assertEquals('dummy-document-hash-id', $config_translation_service
->getDocumentId($entity));
$this
->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
$this
->assertTargetStatus('ES', Lingotek::STATUS_CURRENT);
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertText('Target es for Body was already completed in the TMS and cannot be cancelled unless the entire document is cancelled.');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
}