You are here

function TMGMTEntitySourceListTestCase::testTranslationStatuses in Translation Management Tool 7

File

sources/entity/ui/tmgmt_entity_ui.list.test, line 102

Class

TMGMTEntitySourceListTestCase

Code

function testTranslationStatuses() {

  // Test statuses: Source, Missing.
  $this
    ->drupalGet('admin/tmgmt/sources/entity_node');
  $langstatus_en = $this
    ->xpath('//table[@id="tmgmt-entities-list"]/tbody/tr[1]/td[@class="langstatus-en"]');
  $langstatus_de = $this
    ->xpath('//table[@id="tmgmt-entities-list"]/tbody/tr[1]/td[@class="langstatus-de"]');
  $this
    ->assertEqual($langstatus_en[0]->div['title'], t('Source language'));
  $this
    ->assertEqual($langstatus_de[0]->div['title'], t('Not translated'));

  // Test status: Active job item.
  $job = $this
    ->createJob('en', 'de');
  $job->translator = $this->default_translator->name;
  $job->settings = array();
  $job
    ->save();
  $job
    ->addItem('entity', 'node', $this->nodes['article']['en'][0]->nid);
  $job
    ->requestTranslation();
  $this
    ->drupalGet('admin/tmgmt/sources/entity_node');
  $langstatus_de = $this
    ->xpath('//table[@id="tmgmt-entities-list"]/tbody/tr[1]/td[@class="langstatus-de"]/a');
  $items = $job
    ->getItems();
  $wrapper = entity_metadata_wrapper('tmgmt_job_item', array_shift($items));
  $label = t('Active job item: @state', array(
    '@state' => $wrapper->state
      ->label(),
  ));
  $this
    ->assertEqual($langstatus_de[0]->div['title'], $label);

  // Test status: Current
  foreach ($job
    ->getItems() as $job_item) {
    $job_item
      ->acceptTranslation();
  }
  $this
    ->drupalGet('admin/tmgmt/sources/entity_node');
  $langstatus_de = $this
    ->xpath('//table[@id="tmgmt-entities-list"]/tbody/tr[1]/td[@class="langstatus-de"]');
  $this
    ->assertEqual($langstatus_de[0]->div['title'], t('Translation up to date'));
}