You are here

function TMGMTEntitySourceTestCase::testEntitySourceTerm in Translation Management Tool 7

Tests taxonomy terms field translation.

File

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

Class

TMGMTEntitySourceTestCase
Basic Entity Source tests.

Code

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

  // Create the job.
  $job = $this
    ->createJob();
  $job->translator = $this->default_translator->name;
  $job->settings = array();
  $job
    ->save();
  $term = NULL;

  //Create some terms.
  for ($i = 1; $i <= 5; $i++) {
    $term = $this
      ->createTaxonomyTerm($this->vocabulary);

    // Create the item and assign it to the job.
    $item = $job
      ->addItem('entity', 'taxonomy_term', $term->tid);
    $this
      ->assertEqual(t('@type (@bundle)', array(
      '@type' => t('Taxonomy term'),
      '@bundle' => $this->vocabulary->name,
    )), $item
      ->getSourceType());
  }

  // Request the translation and accept it.
  $job
    ->requestTranslation();

  // Check if the fields were translated.
  foreach ($job
    ->getItems() as $item) {
    $this
      ->assertJobItemLangCodes($item, 'en', array(
      'en',
    ));
    $item
      ->acceptTranslation();
    $entity = entity_load_single($item->item_type, $item->item_id);
    $data = $item
      ->getData();
    $this
      ->checkTranslatedData($entity, $data, 'de');
    $this
      ->checkUntranslatedData($entity, $this->field_names['taxonomy_term'][$this->vocabulary->machine_name], $data, 'de');
    $this
      ->assertJobItemLangCodes($item, 'en', array(
      'de',
      'en',
    ));
  }
}