View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\lingotek\Lingotek;
use Drupal\node\Entity\Node;
class LingotekNodeBulkTranslationTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected $node;
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->saveLingotekContentTranslationSettingsForNodeTypes();
}
public function testNodeTranslationUsingLinks() {
$this
->drupalLogin($this->rootUser);
$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
->drupalLogin($this->translationManagerUser);
$this
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$this
->assertNoLingotekRequestTranslationLink('es_MX');
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool is complete.');
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_MX' was added as a translation target for node Llamas are cool.");
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->assertLingotekCheckTargetStatusLink('es_MX');
$this
->clickLink('ES');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText('The es_MX translation for node Llamas are cool is ready for download.');
$this
->assertLingotekDownloadTargetLink('es_MX');
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool into es_MX has been downloaded.');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('es_MX');
}
public function testNodeTranslationUsingActions() {
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_AT')
->save();
$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
->drupalLogin($this->translationManagerUser);
$this
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_AT');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslation('de', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('de_AT', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->assertLingotekCheckTargetStatusLink('de_AT');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslation('de', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('de_AT', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertLingotekDownloadTargetLink('de_AT');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslation('de', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('de_AT', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('de_AT');
}
public function testNodeTranslationUsingActionsForMultipleLocales() {
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_AT')
->save();
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_AT');
$this
->assertLingotekRequestTranslationLink('es_MX');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->assertLingotekCheckTargetStatusLink('de_AT');
$this
->assertLingotekCheckTargetStatusLink('es_MX');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekDownloadTargetLink('de_AT');
$this
->assertLingotekDownloadTargetLink('es_MX');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('es_MX');
$this
->assertLingotekWorkbenchLink('de_AT');
}
public function testNodeNotMarkedAsEditedIfNotUploaded() {
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_AT')
->save();
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedNodeForm($edit, 1);
$this
->goToContentBulkManagementForm();
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
}
public function testNodeTranslationUsingActionsForMultipleLocalesAfterEditing() {
$this
->testNodeTranslationUsingActionsForMultipleLocales();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedThisTranslationNodeForm($edit, 1);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->clickLink('EN');
$this
->assertLingotekCheckTargetStatusLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekCheckTargetStatusLink('es_MX', 'dummy-document-hash-id-1');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekDownloadTargetLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekDownloadTargetLink('es_MX', 'dummy-document-hash-id-1');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('es_MX', 'dummy-document-hash-id-1');
$this
->assertLingotekWorkbenchLink('de_AT', 'dummy-document-hash-id-1');
}
public function testNodeTranslationUsingActionsForMultipleLocalesAfterEditingWithPendingPhases() {
$this
->testNodeTranslationUsingActionsForMultipleLocales();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedThisTranslationNodeForm($edit, 1);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->clickLink('EN');
\Drupal::state()
->set('lingotek.document_completion', FALSE);
$this
->assertLingotekCheckTargetStatusLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekCheckTargetStatusLink('es_MX', 'dummy-document-hash-id-1');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('DE', 'pending');
$this
->assertTargetStatus('ES', 'pending');
}
public function testNodeMultipleLanguageTranslationUsingActions() {
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_AT')
->save();
$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);
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool 2';
$edit['body[0][value]'] = 'Llamas are very cool 2';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndPublishNodeForm($edit);
$this
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink(1);
$this
->assertLingotekUploadLink(2);
$key1 = $this
->getBulkSelectionKey('en', 1);
$key2 = $this
->getBulkSelectionKey('en', 2);
$edit = [
$key1 => TRUE,
$key2 => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekCheckSourceStatusLink('dummy-document-hash-id');
$this
->assertLingotekCheckSourceStatusLink('dummy-document-hash-id-1');
$edit = [
$key1 => TRUE,
$key2 => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_AT', 'dummy-document-hash-id');
$this
->assertLingotekRequestTranslationLink('es_MX', 'dummy-document-hash-id');
$this
->assertLingotekRequestTranslationLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekRequestTranslationLink('es_MX', 'dummy-document-hash-id-1');
$edit = [
$key1 => TRUE,
$key2 => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekCheckTargetStatusLink('de_AT', 'dummy-document-hash-id');
$this
->assertLingotekCheckTargetStatusLink('es_MX', 'dummy-document-hash-id');
$this
->assertLingotekCheckTargetStatusLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekCheckTargetStatusLink('es_MX', 'dummy-document-hash-id-1');
$edit = [
$key1 => TRUE,
$key2 => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekDownloadTargetLink('de_AT', 'dummy-document-hash-id');
$this
->assertLingotekDownloadTargetLink('es_MX', 'dummy-document-hash-id');
$this
->assertLingotekDownloadTargetLink('de_AT', 'dummy-document-hash-id-1');
$this
->assertLingotekDownloadTargetLink('es_MX', 'dummy-document-hash-id-1');
$edit = [
$key1 => TRUE,
$key2 => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
}
public function testAddContentLinkPresent() {
$this
->drupalLogin($this->rootUser);
$this
->drupalPlaceBlock('local_actions_block');
$this
->goToContentBulkManagementForm();
$this
->clickLink('Add content');
$this
->assertUrl(Url::fromRoute('node.add', [
'node_type' => 'article',
]));
}
public function testEditedNodeTranslationUsingLinks() {
$this
->testNodeTranslationUsingLinks();
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('eu')
->setThirdPartySetting('lingotek', 'locale', 'eu_ES')
->save();
ConfigurableLanguage::createFromLangcode('ko')
->setThirdPartySetting('lingotek', 'locale', 'ko_KR')
->save();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$edit['body[0][value]'] = 'Llamas are very cool EDITED';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndKeepPublishedThisTranslationNodeForm($edit, 1);
$this
->drupalLogin($this->translationManagerUser);
$this
->goToContentBulkManagementForm();
$this
->assertSourceStatus('EN', Lingotek::STATUS_EDITED);
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->assertNoTargetStatus('EU', Lingotek::STATUS_EDITED);
$this
->assertTargetStatus('EU', Lingotek::STATUS_REQUEST);
$this
->clickLink('KO');
$this
->assertText("Locale 'ko_KR' was added as a translation target for node Llamas are cool EDITED.");
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
$this
->assertTargetStatus('KO', 'pending');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool EDITED is complete.');
$this
->assertTargetStatus('KO', 'pending');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', 'ready');
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool EDITED into es_MX has been downloaded.');
}
public function testEditedNodeTranslationUsingLinksInAutomaticUploadsMode() {
$this
->testNodeTranslationUsingLinks();
$this
->drupalLogin($this->rootUser);
ConfigurableLanguage::createFromLangcode('eu')
->setThirdPartySetting('lingotek', 'locale', 'eu_ES')
->save();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$edit['body[0][value]'] = 'Llamas are very cool EDITED';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'automatic';
$this
->saveAndKeepPublishedThisTranslationNodeForm($edit, 1);
$this
->drupalLogin($this->translationManagerUser);
$this
->goToContentBulkManagementForm();
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->assertNoTargetStatus('EU', Lingotek::STATUS_EDITED);
$this
->assertTargetStatus('EU', Lingotek::STATUS_REQUEST);
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool EDITED is complete.');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', 'ready');
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool EDITED into es_MX has been downloaded.');
}
public function testAddingLanguageAllowsRequesting() {
$this
->testNodeTranslationUsingLinks();
ConfigurableLanguage::createFromLangcode('ca')
->save();
$this
->goToContentBulkManagementForm();
$this
->assertLingotekRequestTranslationLink('ca_ES');
$this
->clickLink('CA');
$this
->assertText("Locale 'ca_ES' was added as a translation target for node Llamas are cool.");
}
public function testEditedTranslationIsMarkedAsTargetEditedAndNotTheSource() {
$this
->testNodeTranslationUsingLinks();
$this
->drupalLogin($this->rootUser);
$edit = [];
$edit['title[0][value]'] = 'Las llamas son chulas EDITED';
$this
->saveAndKeepPublishedThisTranslationNodeForm($edit, 1, 'es');
$this
->assertText('Las llamas son chulas EDITED');
$this
->drupalLogin($this->translationManagerUser);
$this
->goToContentBulkManagementForm();
$this
->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
$this
->assertTargetStatus('ES', Lingotek::STATUS_EDITED);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_READY);
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool into es_MX has been downloaded.');
$this
->assertTargetStatus('ES', Lingotek::STATUS_CURRENT);
$this
->drupalGet('es/node/1');
$this
->assertNoText('Las llamas son chulas EDITED');
}
public function testFormWorksAfterRemovingLanguageWithStatuses() {
$this
->testAddingLanguageAllowsRequesting();
ConfigurableLanguage::load('es')
->delete();
$this
->goToContentBulkManagementForm();
$this
->assertNoLink('ES');
$this
->assertLink('CA');
}
public function testAddingContentInDifferentLocale() {
$this
->drupalLogin($this->rootUser);
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool es-MX';
$edit['body[0][value]'] = 'Llamas are very cool es-MX';
$edit['langcode[0][value]'] = 'es';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndPublishNodeForm($edit);
$this
->goToContentBulkManagementForm('node', 'es');
$this
->assertLingotekUploadLink(1, 'node', 'es');
$this
->assertNoLingotekRequestTranslationLink('en_US', 'dummy-document-hash-id', 'node', 'es');
$this
->clickLink('ES');
$this
->assertText('Node Llamas are cool es-MX has been uploaded.');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.uploaded_locale'));
}
public function testUploadingWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('The upload for node Llamas are cool failed. Please try again.');
$this
->assertSourceStatus('EN', 'error');
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
}
public function testUploadingWithAPaymentRequiredError() {
\Drupal::state()
->set('lingotek.must_payment_required_error_in_upload', TRUE);
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_payment_required_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
}
public function testUpdatingWithAnError() {
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->clickLink('EN');
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('The update for node Llamas are cool EDITED failed. Please try again.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testUpdatingWithAPaymentRequiredError() {
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->clickLink('EN');
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_payment_required_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_payment_required_error_in_update', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testUpdatingWithADocumentArchivedError() {
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->clickLink('EN');
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_document_archived_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Document node Llamas are cool EDITED has been archived. Please upload again.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_UNTRACKED, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_document_archived_error_in_update', FALSE);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
}
public function testUpdatingWithADocumentLockedError() {
$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
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->clickLink('EN');
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_document_locked_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('Document node Llamas are cool EDITED has a new version. The document id has been updated for all future interactions. Please try again.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_EDITED);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_EDITED, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_document_locked_error_in_update', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testUploadingWithAnErrorUsingActions() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('The upload for node Llamas are cool failed. Please try again.');
$this
->assertSourceStatus('EN', 'error');
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
}
public function testUploadingWithAPaymentRequiredErrorUsingActions() {
\Drupal::state()
->set('lingotek.must_payment_required_error_in_upload', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_payment_required_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
}
public function testUpdatingWithAnErrorUsingActions() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', 'importing');
$this
->clickLink('EN');
$edit = [
'title[0][value]' => 'Llamas are cool EDITED',
];
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('The update for node Llamas are cool EDITED failed. Please try again.');
$this
->assertSourceStatus('EN', 'error');
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testUpdatingWithADocumentArchivedErrorUsingActions() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->clickLink('EN');
$edit = [
'title[0][value]' => 'Llamas are cool EDITED',
];
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_document_archived_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('Document node Llamas are cool EDITED has been archived. Please upload again.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_UNTRACKED, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_document_archived_error_in_update', FALSE);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
}
public function testUpdatingWithADocumentLockedErrorUsingActions() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->clickLink('EN');
$edit = [
'title[0][value]' => 'Llamas are cool EDITED',
];
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_document_locked_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('Document node Llamas are cool EDITED has a new version. The document id has been updated for all future interactions. Please try again.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_EDITED);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_EDITED, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_document_locked_error_in_update', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testUpdatingWithAPaymentRequiredErrorUsingActions() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->clickLink('EN');
$edit = [
'title[0][value]' => 'Llamas are cool EDITED',
];
$this
->saveAndKeepPublishedNodeForm($edit, 1);
\Drupal::state()
->set('lingotek.must_payment_required_error_in_update', TRUE);
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this->node = Node::load(1);
$translation_service = \Drupal::service('lingotek.content_translation');
$source_status = $translation_service
->getSourceStatus($this->node);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node has been marked as error.');
\Drupal::state()
->set('lingotek.must_payment_required_error_in_update', FALSE);
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
}
public function testCheckTranslationsAction() {
ConfigurableLanguage::create([
'id' => 'de_AT',
'label' => 'German (Austria)',
])
->setThirdPartySetting('lingotek', 'locale', 'de_AT')
->save();
ConfigurableLanguage::createFromLangcode('ca')
->setThirdPartySetting('lingotek', 'locale', 'ca_ES')
->save();
ConfigurableLanguage::createFromLangcode('it')
->setThirdPartySetting('lingotek', 'locale', 'it_IT')
->save();
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_AT', 'dummy-document-hash-id');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekDownloadTargetLink('de_AT');
$this
->assertLingotekDownloadTargetLink('es_MX');
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_DE')
->save();
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekDownloadTargetLink('de_DE');
\Drupal::state()
->set('lingotek.document_completion_statuses', [
'de-AT' => 50,
'de-DE' => 100,
'es-MX' => 10,
]);
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertNoLingotekDownloadTargetLink('de_AT');
$this
->assertLingotekDownloadTargetLink('de_DE');
$this
->assertNoLingotekDownloadTargetLink('es_MX');
$this
->assertLingotekRequestTranslationLink('ca_ES');
$this
->assertLingotekRequestTranslationLink('it_IT');
\Drupal::state()
->set('lingotek.document_completion_statuses', [
'it-IT' => 100,
'de-DE' => 50,
'es-MX' => 10,
]);
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_AT');
$this
->assertLingotekCheckTargetStatusLink('de_DE');
$this
->assertLingotekCheckTargetStatusLink('es_MX');
$this
->assertLingotekRequestTranslationLink('ca_ES');
$this
->assertLingotekDownloadTargetLink('it_IT');
$this
->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
$this
->assertSourceStatusStateCount(Lingotek::STATUS_CURRENT, 'EN', 1);
}
public function testCheckSourceStatusNotCompleted() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
\Drupal::state()
->set('lingotek.document_status_completion', FALSE);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekCheckSourceStatusLink();
\Drupal::state()
->set('lingotek.document_status_completion', TRUE);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('es_MX');
}
public function testCheckSourceStatusNotCompletedAndUploadedLongAgo() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
\Drupal::state()
->set('lingotek.document_status_completion', FALSE);
Node::load(1)
->setChangedTime(REQUEST_TIME - 100000)
->save();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
$this
->assertLingotekUpdateLink();
}
public function testCheckSourceStatusWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_check_source_status', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->clickLink('EN');
$this
->assertNoSourceStatus('EN', Lingotek::STATUS_REQUEST);
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertText('The check for node status failed. Please try again.');
}
public function testCheckSourceStatusActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_check_source_status', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertNoSourceStatus('EN', Lingotek::STATUS_REQUEST);
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertText('The upload status check for node Llamas are cool translation failed. Please try again.');
}
public function testRequestTranslationWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The translation request for node failed. Please try again.');
}
public function testRequestTranslationWithAPaymentRequiredError() {
\Drupal::state()
->set('lingotek.must_payment_required_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
}
public function testRequestTranslationWithADocumentArchivedError() {
\Drupal::state()
->set('lingotek.must_document_archived_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this
->assertNoLingotekRequestTranslationLink('es_MX');
$this
->assertText('Document node Llamas are cool has been archived. Please upload again.');
}
public function testRequestTranslationWithADocumentLockedError() {
\Drupal::state()
->set('lingotek.must_document_locked_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Document node Llamas are cool has a new version. The document id has been updated for all future interactions. Please try again.');
}
public function testRequestTranslationWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The request for node Llamas are cool translation failed. Please try again.');
}
public function testRequestTranslationWithActionWithADocumentArchivedError() {
\Drupal::state()
->set('lingotek.must_document_archived_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this
->assertNoLingotekRequestTranslationLink('es_MX');
$this
->assertText('Document node Llamas are cool has been archived. Please upload again.');
}
public function testRequestTranslationWithActionWithADocumentLockedError() {
\Drupal::state()
->set('lingotek.must_document_locked_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Document node Llamas are cool has a new version. The document id has been updated for all future interactions. Please try again.');
}
public function testRequestTranslationWithActionWithAPaymentRequiredError() {
\Drupal::state()
->set('lingotek.must_payment_required_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
}
public function testRequestAllTranslationsWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The request for node Llamas are cool translation failed. Please try again.');
}
public function testRequestAllTranslationsWithActionWithADocumentArchivedError() {
\Drupal::state()
->set('lingotek.must_document_archived_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this
->assertNoLingotekRequestTranslationLink('es_MX');
$this
->assertText('Document node Llamas are cool has been archived. Please upload again.');
}
public function testRequestAllTranslationsWithActionWithADocumentLockedError() {
\Drupal::state()
->set('lingotek.must_document_locked_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Document node Llamas are cool has a new version. The document id has been updated for all future interactions. Please try again.');
}
public function testRequestAllTranslationsWithActionWithAPaymentRequiredError() {
\Drupal::state()
->set('lingotek.must_payment_required_error_in_request_translation', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForRequestTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');
}
public function testCheckTranslationStatusWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_check_target_status', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->assertText('The request for node translation status failed. Please try again.');
}
public function testCheckTranslationStatusWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_check_target_status', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The request for node Llamas are cool translation status failed. Please try again.');
}
public function testCheckAllTranslationsStatusesWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_check_target_status', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The request for node Llamas are cool translation status failed. Please try again.');
}
public function testDownloadTranslationWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_download', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_READY);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_ERROR);
$this
->assertText('The download for node Llamas are cool failed. Please try again.');
}
public function testDownloadTranslationWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_download', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_READY);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_ERROR);
$this
->assertText('The download for node Llamas are cool translation failed. Please try again.');
}
public function testDownloadAllTranslationsWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_download', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->clickLink('ES');
$this
->assertTargetStatus('ES', Lingotek::STATUS_PENDING);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_READY);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_ERROR);
$this
->assertText('The download for node Llamas are cool translation failed. Please try again.');
}
public function testCancelWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_cancel', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancel('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The cancellation of node Llamas are cool failed. Please try again.');
}
public function testCancelTargetWithActionWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_cancel', TRUE);
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancelTarget('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$this
->assertText('The cancellation of node Llamas are cool translation to es failed. Please try again.');
}
public function testCancelTargetStatusAlwaysKept() {
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->assertTargetStatus('ES', Lingotek::STATUS_REQUEST);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancelTarget('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
\Drupal::state()
->set('lingotek.document_completion_statuses', [
'es_MX' => 'CANCELLED',
]);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
}
public function testTranslationDownloadWithUnrequestedLocales() {
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_DE')
->save();
ConfigurableLanguage::createFromLangcode('it')
->setThirdPartySetting('lingotek', 'locale', 'it_IT')
->save();
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_MX' was added as a translation target for node Llamas are cool.");
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->assertLingotekCheckTargetStatusLink('es_MX');
$this
->clickLink('ES');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText('The es_MX translation for node Llamas are cool is ready for download.');
$this
->assertLingotekDownloadTargetLink('es_MX');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('de_DE');
$this
->assertLingotekRequestTranslationLink('it_IT');
$this
->assertNoTargetError('Llamas are cool', 'DE', 'de_DE');
$this
->assertNoTargetError('Llamas are cool', 'IT', 'it_IT');
}
public function testCheckTranslationsWithDownloadedLocales() {
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_DE')
->save();
ConfigurableLanguage::createFromLangcode('it')
->setThirdPartySetting('lingotek', 'locale', 'it_IT')
->save();
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertLingotekCheckSourceStatusLink();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckUpload('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_MX' was added as a translation target for node Llamas are cool.");
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
\Drupal::state()
->resetCache();
$this
->assertLingotekRequestTranslationLink('it_IT');
$this
->clickLink('IT');
$this
->assertText("Locale 'it_IT' was added as a translation target for node Llamas are cool.");
$this
->assertIdentical('it_IT', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->assertLingotekCheckTargetStatusLink('es_MX');
$this
->clickLink('ES');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText('The es_MX translation for node Llamas are cool is ready for download.');
\Drupal::state()
->resetCache();
$this
->assertLingotekCheckTargetStatusLink('it_IT');
$this
->clickLink('IT');
$this
->assertIdentical('it_IT', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText('The it_IT translation for node Llamas are cool is ready for download.');
$this
->assertLingotekDownloadTargetLink('es_MX');
$this
->assertLingotekDownloadTargetLink('it_IT');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDownloadTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', 'current');
$this
->assertTargetStatus('IT', 'current');
$this
->assertTargetStatus('DE', 'request');
\Drupal::state()
->set('lingotek.document_completion_statuses', [
'es-ES' => 100,
'it-IT' => 100,
]);
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCheckTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertTargetStatus('ES', 'current');
$this
->assertTargetStatus('IT', 'current');
$this
->assertTargetStatus('DE', 'request');
}
public function testDeleteTranslationUpdatesStatuses() {
$this
->testNodeTranslationUsingActionsForMultipleLocales();
$this
->goToContentBulkManagementForm();
$this
->assertTargetStatus('DE', Lingotek::STATUS_CURRENT);
$this
->drupalGet('node/1/translations');
$this
->clickLink('Delete');
$this
->drupalPostForm(NULL, [], t('Delete @language translation', [
'@language' => ConfigurableLanguage::load('de')
->getName(),
]));
$this
->goToContentBulkManagementForm();
$this
->assertTargetStatus('DE', Lingotek::STATUS_READY);
}
public function testDeleteTranslation() {
if ((double) \Drupal::VERSION < 8.6) {
$this
->markTestSkipped("This test doesn't apply for this version of Drupal Core.");
}
$this
->testNodeTranslationUsingActionsForMultipleLocales();
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDeleteTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->confirmBulkDeleteTranslation(1, 1);
$this
->assertLingotekDownloadTargetLink('es_MX');
$this
->assertNoLingotekDownloadTargetLink('de_AT');
}
public function testDeleteMissingTranslation() {
if ((double) \Drupal::VERSION < 8.6) {
$this
->markTestSkipped("This test doesn't apply for this version of Drupal Core.");
}
$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
->goToContentBulkManagementForm();
$this
->assertLingotekUploadLink();
$this
->goToContentBulkManagementForm();
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDeleteTranslation('es', 'node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('No valid translations for deletion.');
$this
->assertSelectionIsKept($key);
$this
->goToContentBulkManagementForm();
$this
->assertNoLingotekDownloadTargetLink('de_AT');
}
public function testDeleteTranslationsInBulk() {
if ((double) \Drupal::VERSION < 8.6) {
$this
->markTestSkipped("This test doesn't apply for this version of Drupal Core.");
}
$this
->testNodeTranslationUsingActionsForMultipleLocales();
ConfigurableLanguage::createFromLangcode('ca')
->setThirdPartySetting('lingotek', 'locale', 'ca_ES')
->save();
$this
->goToContentBulkManagementForm();
$this
->assertLingotekRequestTranslationLink('ca_ES');
$key = $this
->getBulkSelectionKey('en', 1);
$edit = [
$key => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForDeleteTranslations('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->confirmBulkDeleteTranslations(1, 2);
$this
->assertLingotekDownloadTargetLink('es_MX');
$this
->assertLingotekDownloadTargetLink('de_AT');
}
protected function confirmBulkDeleteTranslation($nodeCount, $translationCount) {
$this
->drupalPostForm(NULL, [], t('Delete'));
$this
->assertText("Deleted {$translationCount} content item.");
}
protected function confirmBulkDeleteTranslations($nodeCount, $translationCount) {
$this
->drupalPostForm(NULL, [], t('Delete'));
$this
->assertText("Deleted {$translationCount} content items.");
}
protected function assertSelectionIsKept(string $key) {
$this
->assertOptionSelected($this
->getBulkOperationFormName(), $this
->getBulkOperationNameForDeleteTranslation('es', 'node'));
$this
->assertFieldChecked($key);
}
}