You are here

function TMGMTEntitySourceTestCase::testAddingJobItemsWithEmptySourceText in Translation Management Tool 7

File

sources/entity/tmgmt_entity.source.test, line 108

Class

TMGMTEntitySourceTestCase
Basic Entity Source tests.

Code

function testAddingJobItemsWithEmptySourceText() {
  $this
    ->setEnvironment('de');

  // Create term with empty texts.
  $empty_term = new stdClass();
  $empty_term->name = $this
    ->randomName();
  $empty_term->description = $this
    ->randomName();
  $empty_term->vid = $this->vocabulary->vid;
  taxonomy_term_save($empty_term);

  // Create the job.
  $job = tmgmt_job_create('en', NULL);
  try {
    $job
      ->addItem('entity', 'taxonomy_term', $empty_term->tid);
    $this
      ->fail('Job item added with empty source text.');
  } catch (TMGMTException $e) {
    $this
      ->assert(empty($job->tjid), 'After adding a job item with empty source text its tjid has to be unset.');
  }

  // Create term with populated source content.
  $populated_content_term = $this
    ->createTaxonomyTerm($this->vocabulary);

  // Lets reuse the last created term with populated source content.
  $job
    ->addItem('entity', 'taxonomy_term', $populated_content_term->tid);
  $this
    ->assert(!empty($job->tjid), 'After adding another job item with populated source text its tjid must be set.');
}