function ContentTmgmtEntitySourceListTest::testTranslationStatuses in Translation Management Tool 8
File
- sources/
content/ tests/ src/ Functional/ ContentTmgmtEntitySourceListTest.php, line 132
Class
- ContentTmgmtEntitySourceListTest
- Tests the user interface for entity translation lists.
Namespace
Drupal\Tests\tmgmt_content\FunctionalCode
function testTranslationStatuses() {
// Test statuses: Source, Missing.
$this
->drupalGet('admin/tmgmt/sources/content/node');
$langstatus_en = $this
->xpath('//table[@id="edit-items"]/tbody/tr[1]/td[@class="langstatus-en"]/a/img');
$langstatus_de = $this
->xpath('//table[@id="edit-items"]/tbody/tr[1]/td[@class="langstatus-de"]/img');
$this
->assertEqual($langstatus_en[0]
->getAttribute('title'), t('Original language'));
$this
->assertEqual($langstatus_de[0]
->getAttribute('title'), t('Not translated'));
// Test status: Active job item.
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job->settings = array();
$job
->save();
$job
->addItem('content', 'node', $this->nodes['article']['en'][0]
->id());
$job
->requestTranslation();
$this
->drupalGet('admin/tmgmt/sources/content/node');
$langstatus_de = $this
->xpath('//table[@id="edit-items"]/tbody/tr[1]/td[@class="langstatus-de"]/a/img');
$items = $job
->getItems();
$states = JobItem::getStates();
$label = t('Active job item: @state', array(
'@state' => $states[reset($items)
->getState()],
));
$this
->assertEquals($label, (string) $langstatus_de[0]
->getAttribute('title'));
// Test status: Current
foreach ($job
->getItems() as $job_item) {
$job_item
->acceptTranslation();
}
$this
->drupalGet('admin/tmgmt/sources/content/node');
$langstatus_de = $this
->xpath('//table[@id="edit-items"]/tbody/tr[1]/td[@class="langstatus-de"]/a/img');
$this
->assertEquals(t('Translation up to date'), $langstatus_de[0]
->getAttribute('title'));
// Test status: Inactive job.
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job->settings = array();
$job
->save();
$job
->addItem('content', 'node', $this->nodes['article']['en'][0]
->id());
$this
->drupalGet('admin/tmgmt/sources/content/node');
$langstatus_de = $this
->xpath('//table[@id="edit-items"]/tbody/tr[1]/td[@class="langstatus-de"]/a/img');
$items = $job
->getItems();
$states = JobItem::getStates();
$label = t('Active job item: @state', array(
'@state' => $states[reset($items)
->getState()],
));
$this
->assertEquals($label, (string) $langstatus_de[1]
->getAttribute('title'));
}