public function JobsTest::testAddToJobQueueAsync in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 tests/src/Functional/JobsTest.php \Drupal\Tests\tmgmt_smartling\Functional\JobsTest::testAddToJobQueueAsync()
Add to job form, async mode: two jobs (queue mode).
File
- tests/
src/ Functional/ JobsTest.php, line 818
Class
- JobsTest
- Jobs tests.
Namespace
Drupal\Tests\tmgmt_smartling\FunctionalCode
public function testAddToJobQueueAsync() {
if (!empty($this->smartlingPluginProviderSettings)) {
if (!empty($this->smartlingPluginProviderSettings)) {
$this
->drupalPostForm('/admin/tmgmt/translators/manage/smartling', [
'settings[async_mode]' => TRUE,
], t('Save'));
}
$this
->drupalPostForm('/admin/tmgmt/sources', [
'items[1]' => 1,
'target_language' => '_all',
], t('Request translation'));
$this
->drupalPostForm(NULL, [
'target_language' => 'de',
'settings[switcher]' => TMGMT_SMARTLING_ADD_TO_JOB,
'settings[add_to_job_tab][container][job_info][due_date][date]' => '2020-12-12',
'settings[add_to_job_tab][container][job_info][due_date][time]' => '12:12',
'settings[add_to_job_tab][container][job_info][authorize]' => TRUE,
'settings[smartling_users_time_zone]' => 'Europe/Kiev',
], t('Submit to provider and continue'));
$job1 = Job::load(1);
$job2 = Job::load(2);
$this
->drupalGet('/admin/reports/dblog');
$this
->assertNoText(t('Smartling created a job'));
$this
->assertUniqueText(t('Smartling updated a job'));
$this
->assertUniqueText(t('Smartling created a batch'));
$this
->assertNoText(t('File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job1
->id(),
'@filename' => $job1
->getTranslatorPlugin()
->getFileName($job1),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job1
->id(),
'@filename' => $job1
->getTranslatorPlugin()
->getFileName($job1),
]));
$this
->assertNoText(t('File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job2
->id(),
'@filename' => $job2
->getTranslatorPlugin()
->getFileName($job2),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job2
->id(),
'@filename' => $job2
->getTranslatorPlugin()
->getFileName($job2),
]));
$this
->assertNoText(t('Smartling executed a batch'));
$this
->assertTrue($this
->getCountOfItemsInQueue('tmgmt_extension_suit_upload') == 2);
$this
->assertTrue($this
->getCountOfItemsInQueue('smartling_context_upload') == 0);
$this
->processQueue('tmgmt_extension_suit_upload');
$this
->drupalGet('/admin/reports/dblog');
$this
->assertNoText(t('Smartling created a job'));
$this
->assertUniqueText(t('Smartling updated a job'));
$this
->assertUniqueText(t('Smartling created a batch'));
$this
->assertUniqueText(t('File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job1
->id(),
'@filename' => $job1
->getTranslatorPlugin()
->getFileName($job1),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job1
->id(),
'@filename' => $job1
->getTranslatorPlugin()
->getFileName($job1),
]));
$this
->assertUniqueText(t('File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job2
->id(),
'@filename' => $job2
->getTranslatorPlugin()
->getFileName($job2),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job2
->id(),
'@filename' => $job2
->getTranslatorPlugin()
->getFileName($job2),
]));
$this
->assertUniqueText(t('Smartling executed a batch'));
$this
->assertTrue($this
->getCountOfItemsInQueue('tmgmt_extension_suit_upload') == 0);
$this
->assertTrue($this
->getCountOfItemsInQueue('smartling_context_upload') == 2);
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}