diff --git a/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php index 72a4589..d39322a 100644 --- a/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php +++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php @@ -117,6 +117,28 @@ class ConfigSourceUiTest extends EntityTestBase { } } $this->assertEqual($counter, 2); + + // Test that a job can not be accepted if the translator does not exist. + // Request an italian translation. + $edit = array( + 'languages[it]' => TRUE, + ); + $this->drupalPostForm(NULL, $edit, t('Request translation')); + + // 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')); + + // Try to save, should fail because the job has no translator assigned. + $edit = array( + 'name[translation]' => $this->randomMachineName(), + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + + // Verify that we are on the checkout page. + $this->assertResponse(200); } /** diff --git a/src/Entity/JobItem.php b/src/Entity/JobItem.php index 45d0a45..56689c4 100644 --- a/src/Entity/JobItem.php +++ b/src/Entity/JobItem.php @@ -722,7 +722,7 @@ class JobItem extends ContentEntityBase implements JobItemInterface { break; } } - if ($finished) { + if ($finished && $this->getJob()->hasTranslator()) { // There are no unfinished elements left. if ($this->getJob()->getTranslator()->isAutoAccept()) { // If the job item is going to be auto-accepted, set to review without diff --git a/src/Form/JobItemForm.php b/src/Form/JobItemForm.php index 2ad5c2a..04803e7 100644 --- a/src/Form/JobItemForm.php +++ b/src/Form/JobItemForm.php @@ -201,7 +201,7 @@ 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); }