View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\lingotek\Entity\LingotekProfile;
use Drupal\lingotek\Lingotek;
use Drupal\node\Entity\NodeType;
use Symfony\Component\HttpFoundation\Response;
class LingotekContentTypeNotificationCallbackTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::createFromLangcode('es')
->save();
\Drupal::state()
->set('lingotek.uploaded_content_type', 'content_type');
}
public function testAutomatedNotificationContentTypeTranslation() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
}
public function testManualNotificationContentTypeTranslation() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'manual',
]);
$type = \Drupal::entityTypeManager()
->getStorage('node_type')
->create([
'type' => 'article',
'name' => 'Article',
]);
$type
->save();
\Drupal::service('router.builder')
->rebuild();
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_EDITED, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$this
->clickLink('EN');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([], $response['result']['request_translations'], 'No translations has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_REQUEST, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertEmpty($response['result']['download'], 'No translations has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_READY, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
}
public function testPhaseNotificationContentTypeTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$this
->clickLink('ES');
\Drupal::state()
->set('lingotek.document_completion', 40);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'phase',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_INTERMEDIATE, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->drupalGet('admin/structure/types/manage/article/translate');
$assert_session
->linkByHrefExists('admin/structure/types/manage/article/translate/es/edit');
$this
->goToConfigBulkManagementForm();
\Drupal::state()
->set('lingotek.document_completion', TRUE);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
}
public function testIncompletePhaseNotificationWithNoInterimContentTypeTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$this
->clickLink('ES');
\Drupal::state()
->set('lingotek.document_completion', 40);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'phase',
'progress' => '50',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertFalse($response['result']['download'], 'Spanish language has not been downloaded after notification automatically, as it is interim.');
$this
->assertEqual($response['messages'][0], 'Interim downloads are disabled, so no download for target es_ES happened in document dummy-document-hash-id.', 'Spanish language has not been downloaded after notification automatically, as it is interim.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '50',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertFalse($response['result']['download'], 'Spanish language has not been downloaded after notification automatically, as it is interim.');
$this
->assertEqual($response['messages'][0], 'Interim downloads are disabled, so no download for target es_ES happened in document dummy-document-hash-id.', 'Spanish language has not been downloaded after notification automatically, as it is interim.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
}
public function testIncompletePhaseNotificationWithInterimContentTypeTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalGet('admin/lingotek/settings');
$edit = [
'enable_download_interim' => TRUE,
];
$this
->submitForm($edit, 'Save', 'lingoteksettings-tab-preferences-form');
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$this
->clickLink('ES');
\Drupal::state()
->set('lingotek.document_completion', 40);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'phase',
'progress' => '50',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_INTERMEDIATE, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->drupalGet('admin/structure/types/manage/article/translate');
$assert_session
->linkByHrefExists('admin/structure/types/manage/article/translate/es/edit');
$this
->goToConfigBulkManagementForm();
\Drupal::state()
->set('lingotek.document_completion', TRUE);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '50',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->goToConfigBulkManagementForm();
}
public function testProfileTargetOverridesNotificationContentTypeTranslation() {
$profile = LingotekProfile::create([
'id' => 'profile2',
'label' => 'Profile with overrides',
'auto_upload' => TRUE,
'auto_request' => TRUE,
'auto_download' => TRUE,
'auto_download_worker' => FALSE,
'language_overrides' => [
'es' => [
'overrides' => 'custom',
'custom' => [
'auto_request' => FALSE,
'auto_download' => FALSE,
],
],
],
]);
$profile
->save();
ConfigurableLanguage::createFromLangcode('de')
->save();
ConfigurableLanguage::createFromLangcode('it')
->save();
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'profile2',
]);
$type = \Drupal::entityTypeManager()
->getStorage('node_type')
->create([
'type' => 'article',
'name' => 'Article',
]);
$type
->save();
\Drupal::service('router.builder')
->rebuild();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'body' => http_build_query([]),
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([
'de',
'it',
], $response['result']['request_translations'], 'German and Italian languages has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_REQUEST, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'de'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'body' => http_build_query([]),
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertEmpty($response['result']['download'], 'No translations has been downloaded after notification automatically.');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'de-DE',
'locale' => 'de_DE',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertTrue($response['result']['download'], 'German language has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_READY, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'de'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'de'));
}
public function testProfileRequestTargetOverridesNotificationContentTypeTranslation() {
$profile = LingotekProfile::create([
'id' => 'profile2',
'label' => 'Profile with overrides',
'auto_upload' => TRUE,
'auto_request' => FALSE,
'auto_download' => TRUE,
'auto_download_worker' => FALSE,
'language_overrides' => [
'es' => [
'overrides' => 'custom',
'custom' => [
'auto_request' => TRUE,
'auto_download' => FALSE,
],
],
],
]);
$profile
->save();
ConfigurableLanguage::createFromLangcode('de')
->save();
ConfigurableLanguage::createFromLangcode('it')
->save();
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'profile2',
]);
$type = \Drupal::entityTypeManager()
->getStorage('node_type')
->create([
'type' => 'article',
'name' => 'Article',
]);
$type
->save();
\Drupal::service('router.builder')
->rebuild();
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'body' => http_build_query([]),
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_REQUEST, $config_translation_service
->getTargetStatus($entity, 'de'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'body' => http_build_query([]),
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertEmpty($response['result']['download'], 'No translations has been downloaded after notification automatically.');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'de-DE',
'locale' => 'de_DE',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertEmpty($response['result']['download'], 'No translations has been downloaded after notification automatically.');
$this
->goToConfigBulkManagementForm();
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_READY, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_READY, $config_translation_service
->getTargetStatus($entity, 'de'));
$this
->goToConfigBulkManagementForm();
$this
->clickLink('ES');
$node_storage
->resetCache();
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical(Lingotek::STATUS_READY, $config_translation_service
->getTargetStatus($entity, 'de'));
}
public function testDisabledLanguagesAreNotRequested() {
$italian = ConfigurableLanguage::createFromLangcode('it');
$italian
->save();
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'page',
'name' => 'Page',
], 'Save content type');
$this
->drupalLogin($this->rootUser);
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([
'it',
'es',
], $response['result']['request_translations'], 'Spanish and Italian languages have been requested after notification automatically.');
$lingotek_config = \Drupal::service('lingotek.configuration');
$lingotek_config
->disableLanguage($italian);
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('page');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id-1',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Italian language has not been requested after notification automatically because it is disabled.');
}
public function testTargetDeleted() {
ConfigurableLanguage::createFromLangcode('it')
->save();
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->assertEquals('Document downloaded.', $response['messages'][0]);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'it-IT',
'locale' => 'it_IT',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertTrue($response['result']['download'], 'Italian language has been downloaded after notification automatically.');
$this
->assertEquals('Document downloaded.', $response['messages'][0]);
$this
->goToConfigBulkManagementForm('node_type');
$current_links = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-current')]");
$this
->assertEqual(count($current_links), 2, 'Translation "es_ES" and "it_IT" are current.');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'it-IT',
'locale' => 'it_IT',
'deleted_by_user_login' => 'user@example.com',
'complete' => 'true',
'status' => 'COMPLETE',
'type' => 'target_deleted',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$this
->assertEquals(Response::HTTP_OK, $request
->getStatusCode());
$response = json_decode($request
->getBody(), TRUE);
$this
->assertEquals('Target it_IT for entity Article deleted by user@example.com', $response['messages'][0]);
$this
->goToConfigBulkManagementForm('node_type');
$this
->assertTargetStatus('IT', Lingotek::STATUS_UNTRACKED);
$node_type = NodeType::load('article');
$translation_service = \Drupal::service('lingotek.config_translation');
$this
->assertEquals(Lingotek::STATUS_UNTRACKED, $translation_service
->getTargetStatus($node_type, 'it'));
}
public function testDocumentDeleted() {
ConfigurableLanguage::createFromLangcode('it')
->save();
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'es-ES',
'locale' => 'es_ES',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertTrue($response['result']['download'], 'Spanish language has been downloaded after notification automatically.');
$this
->assertEquals('Document downloaded.', $response['messages'][0]);
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'locale_code' => 'it-IT',
'locale' => 'it_IT',
'complete' => 'true',
'type' => 'target',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertTrue($response['result']['download'], 'Italian language has been downloaded after notification automatically.');
$this
->assertEquals('Document downloaded.', $response['messages'][0]);
$this
->goToConfigBulkManagementForm('node_type');
$current_links = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-current')]");
$this
->assertEquals(count($current_links), 2, 'Translation "es_ES" and "it_IT" are current.');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'deleted_by_user_login' => 'user@example.com',
'complete' => 'true',
'type' => 'document_deleted',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$this
->assertEquals(Response::HTTP_OK, $request
->getStatusCode());
$response = json_decode($request
->getBody(), TRUE);
$this
->assertSame('Document for entity Article deleted by user@example.com in the TMS.', $response['messages'][0]);
$this
->goToConfigBulkManagementForm('node_type');
$this
->assertSourceStatus('EN', Lingotek::STATUS_UNTRACKED);
$this
->assertTargetStatus('IT', Lingotek::STATUS_UNTRACKED);
$this
->assertTargetStatus('ES', Lingotek::STATUS_UNTRACKED);
$node_type = NodeType::load('article');
$translation_service = \Drupal::service('lingotek.config_translation');
$this
->assertEmpty($translation_service
->getDocumentId($node_type));
$this
->assertEquals(Lingotek::STATUS_UNTRACKED, $translation_service
->getTargetStatus($node_type, 'it'));
$this
->assertEquals(Lingotek::STATUS_UNTRACKED, $translation_service
->getTargetStatus($node_type, 'es'));
$this
->assertEquals(Lingotek::STATUS_UNTRACKED, $translation_service
->getSourceStatus($node_type));
}
public function testImportFailureWhileUploading() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'type' => 'import_failure',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical($response['messages'][0], 'Document import for entity Article failed. Reverting dummy-document-hash-id to previous id (NULL)');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertNull($config_translation_service
->getDocumentId($entity));
$this
->assertIdentical(Lingotek::STATUS_ERROR, $config_translation_service
->getSourceStatus($entity));
}
public function testImportFailureWhileUpdating() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->drupalPostForm('/admin/structure/types/manage/article', [
'name' => 'Article EDITED',
], 'Save content type');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id-1');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'prev_document_id' => 'dummy-document-hash-id',
'document_id' => 'dummy-document-hash-id-1',
'type' => 'import_failure',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical($response['messages'][0], 'Document import for entity Article EDITED failed. Reverting dummy-document-hash-id-1 to previous id dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertEquals($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->assertIdentical(Lingotek::STATUS_ERROR, $config_translation_service
->getSourceStatus($entity));
}
public function testDocumentUpdated() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->drupalPostForm('/admin/structure/types/manage/article', [
'name' => 'Article EDITED',
], 'Save content type');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id-1');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id-1',
'complete' => 'false',
'type' => 'document_updated',
'progress' => '100',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertEquals($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id-1');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
}
public function testDocumentCancelledAfterUploading() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'type' => 'document_cancelled',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical($response['messages'][0], 'Document Article cancelled in TMS.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertNull($config_translation_service
->getDocumentId($entity));
$this
->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
->getTargetStatus($entity, 'es'));
}
public function testTargetCancelledAfterUploading() {
$this
->drupalLogin($this->rootUser);
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
$node_storage = $this->container
->get('entity_type.manager')
->getStorage('node_type');
$config_translation_service = \Drupal::service('lingotek.config_translation');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical($config_translation_service
->getDocumentId($entity), 'dummy-document-hash-id');
$this
->goToConfigBulkManagementForm('node_type');
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'complete' => 'false',
'type' => 'document_uploaded',
'progress' => '0',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical([
'es',
], $response['result']['request_translations'], 'Spanish language has been requested after notification automatically.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_PENDING, $config_translation_service
->getTargetStatus($entity, 'es'));
$url = Url::fromRoute('lingotek.notify', [], [
'query' => [
'project_id' => 'test_project',
'document_id' => 'dummy-document-hash-id',
'type' => 'target_cancelled',
'locale' => 'es_ES',
],
])
->setAbsolute()
->toString();
$request = $this->client
->post($url, [
'cookies' => $this->cookies,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'http_errors' => FALSE,
]);
$response = json_decode($request
->getBody(), TRUE);
$this
->verbose($request);
$this
->assertIdentical($response['messages'][0], 'Document Article target es_ES cancelled in TMS.');
$this
->goToConfigBulkManagementForm('node_type');
$entity = $node_storage
->load('article');
$this
->assertIdentical('dummy-document-hash-id', $config_translation_service
->getDocumentId($entity));
$this
->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
->getTargetStatus($entity, 'es'));
}
}