diff -u b/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php b/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php --- b/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php +++ b/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php @@ -451,6 +451,11 @@ $job = tmgmt_job_create('en', 'de'); $job->translator = 'test_translator'; $job->save(); + \Drupal::state()->set('tmgmt.test_source_data', array( + 'title' => array( + '#label' => 'Long llama text', + ), + )); $job_item = tmgmt_job_item_create('test_source', $node->getEntityTypeId(), $node->id(), array('tjid' => $job->id())); $job_item->save(); @@ -459,7 +464,8 @@ $items = $job->getItems(); /** @var \Drupal\tmgmt\Entity\JobItem $item */ $item = reset($items); - // As was set to auto_accept, should be accepted. + // If it was set to Auto Accept but there was an error, the Job Item should + // be set as Needs Review. $this->assertEqual($item->getState(), JobItemInterface::STATE_REVIEW); } diff -u b/tmgmt_test/src/Plugin/tmgmt/Source/TestSource.php b/tmgmt_test/src/Plugin/tmgmt/Source/TestSource.php --- b/tmgmt_test/src/Plugin/tmgmt/Source/TestSource.php +++ b/tmgmt_test/src/Plugin/tmgmt/Source/TestSource.php @@ -3,7 +3,6 @@ namespace Drupal\tmgmt_test\Plugin\tmgmt\Source; use Drupal\Component\Render\FormattableMarkup; -use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Url; use Drupal\tmgmt\JobItemInterface; use Drupal\tmgmt\SourcePluginBase; @@ -102,8 +101,8 @@ public function saveTranslation(JobItemInterface $job_item, $target_langcode) { // Set a variable that can be checked later for a given job item. $data = $job_item->getData(); - if ($data['dummy']['deep_nesting']['#translation']['#text']) { - throw new DatabaseExceptionWrapper('The translation cannot be saved.'); + if (!isset($data['title']['#label'])) { + throw new \Exception('The translation cannot be saved.'); } \Drupal::state()->set('tmgmt_test_saved_translation_' . $job_item->getItemType() . '_' . $job_item->getItemId(), $job_item->getData()); return TRUE;