public function LocalTranslatorTest::testVBOPermissions in Translation Management Tool 8
Test permissions for the tmgmt_local VBO actions.
File
- translators/
tmgmt_local/ tests/ src/ Functional/ LocalTranslatorTest.php, line 742
Class
- LocalTranslatorTest
- Basic tests for the local translator.
Namespace
Drupal\Tests\tmgmt_local\FunctionalCode
public function testVBOPermissions() {
$translator = Translator::load('local');
$job = $this
->createJob();
$job->translator = $translator
->id();
$job->settings->job_comment = $job_comment = 'Dummy job comment';
$job
->addItem('test_source', 'test', '1');
$job
->addItem('test_source', 'test', '2');
// Create another local translator with the required abilities.
$assignee = $this
->loginAsTranslator($this->localTranslatorPermissions);
// Configure language abilities.
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $assignee
->id() . '/edit', $edit, t('Save'));
$job
->requestTranslation();
$this
->drupalGet('manage-translate');
$this
->assertResponse(403);
$this
->drupalGet('translate');
$edit = array(
'tmgmt_local_task_bulk_form[0]' => TRUE,
'action' => 'tmgmt_local_task_assign_to_me',
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$this
->assertText(t('Assign to me was applied to 1 item.'));
$edit = array(
'tmgmt_local_task_bulk_form[0]' => TRUE,
'action' => 'tmgmt_local_task_unassign_multiple',
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$this
->assertText(t('Unassign was applied to 1 item.'));
// Login as admin and check VBO submit actions are present.
$this
->loginAsAdmin($this->localManagerPermissions);
$this
->drupalGet('manage-translate');
$edit = array(
'tmgmt_local_task_bulk_form[0]' => TRUE,
'action' => 'tmgmt_local_task_assign_multiple',
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$edit = array(
'tuid' => $assignee
->id(),
);
$this
->drupalPostForm(NULL, $edit, t('Assign tasks'));
$this
->assertText(t('Assigned 1 to user @assignee.', [
'@assignee' => $assignee
->getAccountName(),
]));
}