public function LocalTranslatorTest::testAssigneeSkillsForTasks in Translation Management Tool 8
Test assignee skills.
File
- translators/
tmgmt_local/ tests/ src/ Functional/ LocalTranslatorTest.php, line 21
Class
- LocalTranslatorTest
- Basic tests for the local translator.
Namespace
Drupal\Tests\tmgmt_local\FunctionalCode
public function testAssigneeSkillsForTasks() {
$this
->addLanguage('fr');
$assignee1 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$this
->drupalLogin($assignee1);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'en',
);
$this
->drupalPostForm('user/' . $assignee1
->id() . '/edit', $edit, t('Save'));
$this
->assertText('The \'from\' and \'to\' language fields can\'t have the same value.');
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $assignee1
->id() . '/edit', $edit, t('Save'));
$this
->assertText('The changes have been saved.');
$edit = array(
'tmgmt_translation_skills[1][language_from]' => 'en',
'tmgmt_translation_skills[1][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $assignee1
->id() . '/edit', $edit, t('Save'));
$this
->assertText('The language combination has to be unique.');
$assignee2 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$this
->drupalLogin($assignee2);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $assignee2
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[1][language_from]' => 'de',
'tmgmt_translation_skills[1][language_to]' => 'en',
);
$this
->drupalPostForm('user/' . $assignee2
->id() . '/edit', $edit, t('Save'));
$assignee3 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$this
->drupalLogin($assignee3);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $assignee3
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[1][language_from]' => 'de',
'tmgmt_translation_skills[1][language_to]' => 'en',
);
$this
->drupalPostForm('user/' . $assignee3
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[2][language_from]' => 'en',
'tmgmt_translation_skills[2][language_to]' => 'fr',
);
$this
->drupalPostForm('user/' . $assignee3
->id() . '/edit', $edit, t('Save'));
$job1 = $this
->createJob('en', 'de');
$job2 = $this
->createJob('de', 'en');
$job3 = $this
->createJob('en', 'fr');
$local_task1 = LocalTask::create(array(
'uid' => $job1
->getOwnerId(),
'tjid' => $job1
->id(),
'title' => 'Task 1',
));
$local_task1
->save();
$local_task2 = LocalTask::create(array(
'uid' => $job2
->getOwnerId(),
'tjid' => $job2
->id(),
'title' => 'Task 2',
));
$local_task2
->save();
$local_task3 = LocalTask::create(array(
'uid' => $job3
->getOwnerId(),
'tjid' => $job3
->id(),
'title' => 'Task 3',
));
$local_task3
->save();
// Test languages involved in tasks.
$this
->assertEqual(tmgmt_local_tasks_languages(array(
$local_task1
->id(),
$local_task2
->id(),
$local_task3
->id(),
)), array(
'en' => array(
'de',
'fr',
),
'de' => array(
'en',
),
));
// Test available translators for task en - de.
$this
->assertEqual(tmgmt_local_get_assignees_for_tasks(array(
$local_task1
->id(),
)), array(
$assignee1
->id() => $assignee1
->getDisplayName(),
$assignee2
->id() => $assignee2
->getDisplayName(),
$assignee3
->id() => $assignee3
->getDisplayName(),
));
// Test available translators for tasks en - de, de - en.
$this
->assertEqual(tmgmt_local_get_assignees_for_tasks(array(
$local_task1
->id(),
$local_task2
->id(),
)), array(
$assignee2
->id() => $assignee2
->getDisplayName(),
$assignee3
->id() => $assignee3
->getDisplayName(),
));
// Test available translators for tasks en - de, de - en, en - fr.
$this
->assertEqual(tmgmt_local_get_assignees_for_tasks(array(
$local_task1
->id(),
$local_task2
->id(),
$local_task3
->id(),
)), array(
$assignee3
->id() => $assignee3
->getDisplayName(),
));
}