diff --git a/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php index 72a4589..87c4248 100644 --- a/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php +++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php @@ -117,6 +117,33 @@ class ConfigSourceUiTest extends EntityTestBase { } } $this->assertEqual($counter, 2); + + // Request an italian translation. + $edit = array( + 'languages[it]' => TRUE, + ); + $this->drupalPostForm(NULL, $edit, t('Request translation')); + + // Verify that we are on the checkout page. + $this->assertText(t('One job needs to be checked out.')); + $this->assertText('Article content type (English to Italian, Unprocessed)'); + + // Go back to the originally defined destination URL without submitting. + $this->drupalGet('admin/structure/types/manage/article/translate'); + + // Verify that the pending translation is shown. + $this->clickLink(t('In progress')); + + // Verify that the title of the preview page exists. + $this->assertText(t('Job item Article content type')); + + $edit = array( + 'name[translation]' => $this->randomMachineName(), + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + + // Verify that the an error message for the translator exists. + $this->assertText(t('The job item could not be saved because the job does not have a translator assigned.')); } /** diff --git a/src/Form/JobItemForm.php b/src/Form/JobItemForm.php index 2ad5c2a..699db05 100644 --- a/src/Form/JobItemForm.php +++ b/src/Form/JobItemForm.php @@ -201,10 +201,13 @@ class JobItemForm extends TmgmtFormBase { $source_ui = $this->sourceManager->createUIInstance($item->getPlugin()); $source_ui->reviewFormValidate($form, $form_state, $item); // Invoke the validation method on the translator controller (if available). - if ($item->getTranslator()) { + if ($item->hasTranslator()) { $translator_ui = $this->translatorManager->createUIInstance($item->getTranslator()->getPluginId()); $translator_ui->reviewFormValidate($form, $form_state, $item); } + else { + $form_state->setErrorByName('accept', $this->t('The job item could not be saved because the job does not have a translator assigned.')); + } foreach ($form_state->getValues() as $key => $value) { if (is_array($value) && isset($value['translation'])) { // If there is an empty field then sets and error to fill it.