public function LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 4.0.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.1.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.2.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.3.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.4.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.5.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.6.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.7.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
- 3.8.x tests/src/Functional/LingotekContentTypeNotificationCallbackTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeNotificationCallbackTest::testDisabledLanguagesAreNotRequested()
Tests that there are no automatic requests for disabled languages.
File
- tests/
src/ Functional/ LingotekContentTypeNotificationCallbackTest.php, line 960
Class
- LingotekContentTypeNotificationCallbackTest
- Tests translating a content type using the notification callback.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testDisabledLanguagesAreNotRequested() {
// Add a language.
$italian = ConfigurableLanguage::createFromLangcode('it');
$italian
->save();
// Enable translation for the current entity type and ensure the change is
// picked up.
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
// Create Article node types. We use the form at least once to ensure that
// we don't break anything. E.g. see https://www.drupal.org/node/2645202.
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'article',
'name' => 'Article',
], 'Save content type');
// Create Page node type. We use the form at least once to ensure that
// we don't break anything. E.g. see https://www.drupal.org/node/2645202.
$this
->drupalPostForm('/admin/structure/types/add', [
'type' => 'page',
'name' => 'Page',
], 'Save content type');
// Login as admin.
$this
->drupalLogin($this->rootUser);
/** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
$config_translation_service = \Drupal::service('lingotek.config_translation');
// Assert the content is importing.
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertIdentical(Lingotek::STATUS_IMPORTING, $config_translation_service
->getSourceStatus($entity));
// Go to the bulk config management page.
$this
->goToConfigBulkManagementForm('node_type');
// Simulate the notification of content successfully uploaded.
$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.');
/** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
$lingotek_config = \Drupal::service('lingotek.configuration');
$lingotek_config
->disableLanguage($italian);
// Test with another content.
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('page');
// Simulate the notification of content successfully uploaded.
$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.');
}