function RequestBulkTranslationTest::testRequestBulkTranslationValidation in TMGMT Extension Suite 8
Test validation for bulk translation.
File
- src/
Tests/ RequestBulkTranslationTest.php, line 78
Class
- RequestBulkTranslationTest
- Class RequestBulkTranslationTest
Namespace
Drupal\tmgmt_extension_suit\TestsCode
function testRequestBulkTranslationValidation() {
$settings = [
'body' => [
[
'value' => $this
->randomMachineName(32),
'format' => filter_default_format(),
],
],
'title' => $this
->randomMachineName(8),
'type' => 'translatable_node',
'uid' => \Drupal::currentUser()
->id(),
'langcode' => 'fr',
];
$node = Node::create($settings);
$node
->save();
// Didn't select any nodes.
$this
->requestBulkTranslation([], []);
$this
->assertText("You didn't select any source items.");
// Select nodes with different source languages.
$this
->requestBulkTranslation([
3,
$node
->id(),
], []);
$this
->assertText("You can't request translation in a batch for items in different source languages.");
// Selected source language != entity source language.
$this
->drupalPostForm('admin/tmgmt/sources', [
'items[1]' => 'item[1]',
'source_language' => 'de',
], t('Request translation in a batch'));
$this
->assertText('From the selection you made it was not possible to create any translation job.');
// Select nodes with same source languages.
$this
->requestBulkTranslation([
2,
3,
], []);
$this
->assertTitle("Request translation | Drupal");
}