public function JobsTest::testCreateJobSingleAsync in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 tests/src/Functional/JobsTest.php \Drupal\Tests\tmgmt_smartling\Functional\JobsTest::testCreateJobSingleAsync()
Create job form, async mode: single job.
File
- tests/
src/ Functional/ JobsTest.php, line 507
Class
- JobsTest
- Jobs tests.
Namespace
Drupal\Tests\tmgmt_smartling\FunctionalCode
public function testCreateJobSingleAsync() {
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,
], t('Request translation'));
$this
->drupalPostForm(NULL, [
'target_language' => 'de',
'settings[create_new_job_tab][name]' => 'Drupal TMGMT connector test ' . mt_rand(),
'settings[create_new_job_tab][due_date][date]' => '2020-12-12',
'settings[create_new_job_tab][due_date][time]' => '12:12',
'settings[create_new_job_tab][authorize]' => TRUE,
'settings[smartling_users_time_zone]' => 'Europe/Kiev',
], t('Submit to provider'));
$this
->assertText(t('Job has been put into upload queue.'));
$job = Job::load(1);
$this
->drupalGet('/admin/reports/dblog');
$this
->assertUniqueText(t('Smartling created a job'));
$this
->assertNoText(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' => $job
->id(),
'@filename' => $job
->getTranslatorPlugin()
->getFileName($job),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job
->id(),
'@filename' => $job
->getTranslatorPlugin()
->getFileName($job),
]));
$this
->assertNoText(t('Smartling executed a batch'));
$this
->assertTrue($this
->getCountOfItemsInQueue('tmgmt_extension_suit_upload') == 1);
$this
->assertTrue($this
->getCountOfItemsInQueue('smartling_context_upload') == 0);
$this
->processQueue('tmgmt_extension_suit_upload');
$this
->drupalGet('/admin/reports/dblog');
$this
->assertUniqueText(t('Smartling created a job'));
$this
->assertNoText(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' => $job
->id(),
'@filename' => $job
->getTranslatorPlugin()
->getFileName($job),
]));
$this
->assertNoText(t('Fallback: File uploaded. Job id: @job_id, file name: @filename.', [
'@job_id' => $job
->id(),
'@filename' => $job
->getTranslatorPlugin()
->getFileName($job),
]));
$this
->assertUniqueText(t('Smartling executed a batch'));
$this
->assertTrue($this
->getCountOfItemsInQueue('tmgmt_extension_suit_upload') == 0);
$this
->assertTrue($this
->getCountOfItemsInQueue('smartling_context_upload') == 1);
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}