class LocalTranslatorTest in Translation Management Tool 8
Basic tests for the local translator.
@group tmgmt
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses FunctionalTestSetupTrait, TestSetupTrait, AssertLegacyTrait, BlockCreationTrait, ConfigTestTrait, ContentTypeCreationTrait, NodeCreationTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\tmgmt\Functional\TMGMTTestBase uses TmgmtTestTrait
- class \Drupal\Tests\tmgmt_local\Functional\LocalTranslatorTestBase uses TmgmtEntityTestTrait
- class \Drupal\Tests\tmgmt_local\Functional\LocalTranslatorTest
- class \Drupal\Tests\tmgmt_local\Functional\LocalTranslatorTestBase uses TmgmtEntityTestTrait
- class \Drupal\Tests\tmgmt\Functional\TMGMTTestBase uses TmgmtTestTrait
Expanded class hierarchy of LocalTranslatorTest
File
- translators/
tmgmt_local/ tests/ src/ Functional/ LocalTranslatorTest.php, line 16
Namespace
Drupal\Tests\tmgmt_local\FunctionalView source
class LocalTranslatorTest extends LocalTranslatorTestBase {
/**
* Test assignee skills.
*/
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(),
));
}
/**
* Test the basic translation workflow.
*/
public function testBasicWorkflow() {
$translator = Translator::load('local');
/** @var FilterFormat $basic_html_format */
$basic_html_format = FilterFormat::create(array(
'format' => 'basic_html',
'name' => 'Basic HTML',
));
$basic_html_format
->save();
// Create a job and request a local translation.
$this
->loginAsTranslator();
$job = $this
->createJob();
$job->translator = $translator
->id();
$job
->addItem('test_source', 'test', '1');
\Drupal::state()
->set('tmgmt.test_source_data', [
'dummy' => [
'deep_nesting' => [
'#text' => file_get_contents(drupal_get_path('module', 'tmgmt') . '/tests/testing_html/sample.html'),
'#label' => 'Label for job item with type test and id 2.',
'#translate' => TRUE,
'#format' => 'basic_html',
],
],
'second' => [
'#text' => 'second text',
'#label' => 'Second label',
'#translate' => TRUE,
],
'third' => [
'#text' => 'third text',
'#label' => 'Third label',
'#translate' => TRUE,
],
]);
$job
->addItem('test_source', 'test', '2');
$job
->save();
// Make sure that the checkout page works as expected when there are no
// roles.
$this
->drupalGet($job
->toUrl());
$this
->assertText(t('@translator can not translate from @source to @target.', array(
'@translator' => 'Drupal user',
'@source' => 'English',
'@target' => 'German',
)));
$element = $this
->xpath('//*[@id="edit-translator"]/option')[0];
$this
->assertEqual($element
->getText(), 'Drupal user (unsupported)');
$this->assignee = $this
->drupalCreateUser(array_merge($this->localTranslatorPermissions, [
$basic_html_format
->getPermissionName(),
]));
// The same when there is a single role.
$this
->drupalGet($job
->toUrl());
$this
->assertText(t('@translator can not translate from @source to @target.', array(
'@translator' => 'Drupal user',
'@source' => 'English',
'@target' => 'German',
)));
// Create another local translator with the required abilities.
$other_assignee_same = $this
->drupalCreateUser($this->localTranslatorPermissions);
// And test again with two roles but still no abilities.
$this
->drupalGet($job
->toUrl());
$this
->assertText(t('@translator can not translate from @source to @target.', array(
'@translator' => 'Drupal user',
'@source' => 'English',
'@target' => 'German',
)));
$this
->drupalLogin($other_assignee_same);
// Configure language abilities.
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $other_assignee_same
->id() . '/edit', $edit, t('Save'));
// Check that the user is not listed in the translator selection form.
$this
->loginAsAdmin();
$this
->drupalGet($job
->toUrl());
$element = $this
->xpath('//*[@id="edit-translator"]/option')[0];
$this
->assertEqual($element
->getText(), 'Drupal user');
$this
->assertText(t('Assign job to'));
$this
->assertText($other_assignee_same
->getDisplayName());
$this
->assertNoText($this->assignee
->getDisplayName());
$this
->drupalLogin($this->assignee);
// Configure language abilities.
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $this->assignee
->id() . '/edit', $edit, t('Save'));
// Check that the translator is now listed.
$this
->loginAsAdmin();
$this
->drupalGet($job
->toUrl());
$this
->assertText($this->assignee
->getDisplayName());
// Test assign task while submitting job.
$job_comment = 'Dummy job comment';
$edit = [
'settings[translator]' => $this->assignee
->id(),
'settings[job_comment]' => $job_comment,
];
$this
->drupalPostForm(NULL, $edit, t('Submit to provider'));
$this
->drupalLogin($this->assignee);
$this
->drupalGet('translate/pending');
$this
->assertText($job
->label());
$this
->loginAsAdmin($this->localManagerPermissions);
$this
->drupalGet('manage-translate/assigned');
$this
->assertNoLink(t('Delete'));
$this
->clickLink(t('Unassign'));
$this
->drupalPostForm(NULL, [], t('Unassign'));
// Test for job comment in the job checkout info pane.
$this
->drupalGet($job
->toUrl());
$this
->assertText($job_comment);
$this
->drupalLogin($this->assignee);
// Create a second local translator with different language abilities,
// make sure that he does not see the task.
$other_translator = $this
->drupalCreateUser($this->localTranslatorPermissions);
$this
->drupalLogin($other_translator);
// Configure language abilities.
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'de',
'tmgmt_translation_skills[0][language_to]' => 'en',
);
$this
->drupalPostForm('user/' . $other_translator
->id() . '/edit', $edit, t('Save'));
$this
->drupalGet('translate');
$this
->assertNoText($job
->label());
$this
->drupalLogin($this->assignee);
// Check the translate overview.
$this
->drupalGet('translate');
$this
->assertText($job
->label());
// @todo: Fails, encoding problem?
// $this->assertText(t('@from => @to', array('@from' => 'en', '@to' => 'de')));
// Test LocalTaskForm.
$this
->clickLink('View');
$this
->assertText('Unassigned');
$xpath = $this
->xpath('//*[@id="edit-status"]');
$this
->assertEmpty($xpath);
$this
->loginAsAdmin($this->localManagerPermissions);
$this
->drupalGet('translate');
$this
->clickLink('View');
$xpath = $this
->xpath('//*[@id="edit-tuid"]');
$this
->assertNotEmpty($xpath);
$edit = array(
'tuid' => $this->assignee
->id(),
);
$this
->drupalPostForm(NULL, $edit, t('Save task'));
$this
->assertText(t('Assigned to user @assignee.', [
'@assignee' => $this->assignee
->getDisplayName(),
]));
$this
->drupalGet('manage-translate/assigned');
$this
->clickLink('View');
$edit = array(
'tuid' => 0,
);
$this
->drupalPostForm(NULL, $edit, t('Save task'));
$this
->drupalLogin($this->assignee);
$this
->drupalGet('translate');
// Assign to action not working yet.
$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.'));
// Unassign again.
$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.'));
// Now test the assign link.
// @todo Action should not redirect to mine.
$this
->drupalGet('translate');
$this
->clickLink(t('Assign to me'));
$this
->assertText(t('The task has been assigned to you.'));
// Assert created local task and task items.
$this
->drupalGet('translate/pending');
$this
->clickLink(t('View'));
$this
->assertNotEmpty(preg_match('|translate/(\\d+)|', $this
->getUrl(), $matches), 'Task found');
/** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->load($matches[1]);
$this
->assertTrue($task
->isPending());
$items = $task
->getItems();
/** @var \Drupal\tmgmt_local\Entity\LocalTaskItem $first_task_item */
$first_task_item = reset($items);
$this
->assertTrue($first_task_item
->isPending());
// Log in with the translator with the same abilities, make sure that he
// does not see the assigned task.
$this
->drupalLogin($other_assignee_same);
$this
->drupalGet('translate');
$this
->assertNoText($job
->label());
$this
->drupalGet('translate/items/' . $first_task_item
->id());
$this
->assertResponse(403);
$this
->drupalLogin($this->admin_user);
// Unassign the task.
$this
->drupalGet('translate/' . $task
->id());
$edit = [
'tuid' => '',
];
$this
->drupalPostForm(NULL, $edit, t('Save task'));
$this
->clickLink(t('View'));
// Assign again the task to himself.
$edit = [
'tuid' => $this->assignee
->id(),
];
$this
->drupalPostForm(NULL, $edit, t('Save task'));
$this
->drupalLogin($this->assignee);
// Translate the task.
$this
->drupalGet('translate/' . $task
->id());
$this
->assertText('test_source:test:1');
$this
->assertText('test_source:test:2');
// Translate the first item.
$this
->drupalGet($first_task_item
->toUrl());
// Assert the breadcrumb.
$this
->assertLink(t('Home'));
$this
->assertLink(t('Local Tasks'));
$this
->assertText($job
->label());
// Assert the header.
$this
->assertLink($first_task_item
->getJobItem()
->getSourceLabel());
$this
->assertText($first_task_item
->getJobItem()
->getSourceType());
$this
->assertText($first_task_item
->getJobItem()
->getJob()
->getSourceLanguage()
->getName());
$this
->assertText($first_task_item
->getJobItem()
->getJob()
->getTargetLanguage()
->getName());
$this
->assertText(\Drupal::service('date.formatter')
->format($first_task_item
->getChangedTime()));
$this
->assertText($first_task_item
->getStatus());
$this
->assertLink($first_task_item
->getTask()
->label());
$this
->assertText(t('Dummy'));
// Check if Save as completed button is displayed.
$elements = $this
->xpath('//*[@id="edit-save-as-completed"]');
$this
->assertTrue(!empty($elements), "'Save as completed' button appears.");
// Job comment is present in the translate tool as well.
$this
->assertText($job_comment);
$this
->assertText('test_source:test:1');
// Try to complete a translation when translations are missing.
$edit = array(
'dummy|deep_nesting[translation]' => '',
);
$this
->drupalPostForm(NULL, $edit, t('Save as completed'));
$this
->assertText(t('Missing translation.'));
$edit = array(
'dummy|deep_nesting[translation]' => $translation1 = 'German translation of source 1',
);
$this
->drupalPostForm(NULL, $edit, t('Save as completed'));
$this
->assertRaw('tmgmt/icons/gray-check.svg" title="Translated"');
$this
->assertText('The translation for ' . $first_task_item
->label() . ' has been saved as completed.');
// Check that the source has not being modified.
$this
->clickLink(t('View'));
/** @var \Drupal\tmgmt\JobItemInterface $job_item */
$job_items = $job
->getItems([
'tjiid' => 1,
]);
$job_item = reset($job_items);
$source = $job_item
->getData([
'dummy',
'deep_nesting',
'#text',
]);
$this
->assertText($source);
// Review and accept the first item.
\Drupal::entityTypeManager()
->getStorage('tmgmt_job_item')
->resetCache();
drupal_static_reset('tmgmt_local_task_statistics_load');
/** @var \Drupal\tmgmt\JobItemInterface $item1 */
$item1 = JobItem::load(1);
// The first item should be available for review.
$this
->assertTrue($item1
->isNeedsReview(), 'Job item 1 needs review.');
$item1
->acceptTranslation();
// The first item should be accepted now, the second still in progress.
\Drupal::entityTypeManager()
->getStorage('tmgmt_local_task_item')
->resetCache();
$this
->drupalGet('translate/1');
// Checking if the 'Save as completed' button is not displayed.
$this
->drupalGet('translate/items/1');
$elements = $this
->xpath('//*[@id="edit-save-as-completed"]');
$this
->assertTrue(empty($elements), "'Save as completed' button does not appear.");
// Checking if the item status is not displayed.
$this
->assertNoRaw('title="Finish"');
$this
->assertNoRaw('title="Reject"');
// We can go back to the Task from the item.
$this
->drupalGet('translate/items/1');
$this
->clickLink($task
->label());
// Let's check the task status.
/** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->loadUnchanged($task
->id());
$this
->assertTrue($task
->isPending());
/** @var \Drupal\tmgmt_local\Entity\LocalTaskItem $second_task_item */
list($first_task_item, $second_task_item) = array_values($task
->getItems());
$this
->assertTrue($first_task_item
->isClosed());
// Assert that translator can provide translations for a "Dummy" field. An
// empty text field should be displayed as translator does not have a
// permission to use "full_html" text format.
$second_task_item
->updateData('dummy|deep_nesting', [
'#format' => 'full_html',
]);
$second_task_item
->save();
$this
->clickLink(t('Translate'));
$this
->assertFieldByName('dummy|deep_nesting[translation]');
$this
->assertRaw('Save as completed" class="button button--primary js-form-submit form-submit"');
$translation_field = $this
->xpath('//*[@id="edit-dummydeep-nesting-translation"]')[0];
$this
->assertEqual($translation_field
->getText(), '');
// Translate the second item but do not mark as translated it yet.
$second_task_item
->updateData('dummy|deep_nesting', [
'#format' => 'basic_html',
]);
$second_task_item
->save();
$this
->drupalGet('translate/items/' . $second_task_item
->id());
$title = $this
->xpath('//*[@id="edit-dummydeep-nesting-translation-format-guidelines"]/div/h4')[0];
$this
->assertEqual($title
->getText(), t('Basic HTML'));
// Assert the order of the displayed elements.
$translate_elements = $this
->xpath('//*[@id="edit-translation"]/table');
$ids = [];
foreach ($translate_elements as $translate_element) {
$ids[] = (string) $translate_element
->getAttribute('id');
}
$this
->assertEqual($ids[0], 'tmgmt-local-element-dummy-deep-nesting');
$this
->assertEqual($ids[1], 'tmgmt-local-element-second');
$this
->assertEqual($ids[2], 'tmgmt-local-element-third');
$edit = array(
'dummy|deep_nesting[translation][value]' => $translation2 = 'German translation of source 2',
);
$this
->drupalPostForm(NULL, $edit, t('Save'));
$this
->assertText('The translation for ' . $second_task_item
->label() . ' has been saved.');
drupal_static_reset('tmgmt_local_task_statistics_load');
/** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->loadUnchanged($task
->id());
$this
->assertTrue($task
->isPending());
// Mark the data item as translated but don't save the task item as
// completed.
$this
->clickLink(t('Translate'));
$page = $this
->getSession()
->getPage();
$page
->pressButton('finish-dummy|deep_nesting');
$this
->assertRaw('name="reject-dummy|deep_nesting"', "'✗' button appears.");
$this
->drupalGet('translate/' . $task
->id());
\Drupal::entityTypeManager()
->getStorage('tmgmt_local_task_item')
->resetCache();
drupal_static_reset('tmgmt_local_task_statistics_load');
/** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->loadUnchanged($task
->id());
$this
->assertTrue($task
->isPending());
list($first_task_item, $second_task_item) = array_values($task
->getItems());
$this
->assertTrue($first_task_item
->isClosed());
$this
->assertTrue($second_task_item
->isPending());
// Check the job data.
\Drupal::entityTypeManager()
->getStorage('tmgmt_job_item')
->resetCache();
/** @var \Drupal\tmgmt\JobInterface $job */
$job = Job::load($job
->id());
/** @var \Drupal\tmgmt\JobItemInterface $item2 */
list($item1, $item2) = array_values($job
->getItems());
$this
->assertTrue($item1
->isAccepted(), 'Job item 1 is accepted.');
// The first item should be active.
$this
->assertTrue($item2
->isActive(), 'Job item 2 is still active.');
// Check the overview page, the task should still show in progress.
$this
->drupalGet('translate');
$this
->assertText(t('Pending'));
// Mark the second item as completed now.
$this
->clickLink(t('View'));
$this
->clickLink(t('Translate'));
$remaining_translations = [
'second[translation]' => 'Third translation',
'third[translation]' => 'Third translation',
];
$this
->drupalPostForm(NULL, $remaining_translations, t('Save as completed'));
$this
->assertText('The translation for ' . $second_task_item
->label() . ' has been saved as completed.');
$this
->clickLink('View');
// Review and accept the second item.
\Drupal::entityTypeManager()
->getStorage('tmgmt_job_item')
->resetCache();
drupal_static_reset('tmgmt_local_task_statistics_load');
$item1 = JobItem::load(2);
$item1
->acceptTranslation();
// Refresh the page.
$this
->drupalGet('translate');
// We should have been redirect back to the overview, the task should be
// completed now.
$this
->assertNoText($task
->getJob()
->label());
$this
->clickLink(t('Closed'));
$this
->assertText($task
->getJob()
->label());
$this
->assertText(t('Completed'));
\Drupal::entityTypeManager()
->getStorage('tmgmt_local_task_item')
->resetCache();
$task = LocalTask::load($task
->id());
$this
->assertTrue($task
->isClosed());
list($first_task_item, $second_task_item) = array_values($task
->getItems());
$this
->assertTrue($first_task_item
->isClosed());
$this
->assertTrue($second_task_item
->isClosed());
\Drupal::entityTypeManager()
->getStorage('tmgmt_job_item')
->resetCache();
$job = Job::load($job
->id());
list($item1, $item2) = array_values($job
->getItems());
// Job was accepted and finished automatically due to the default approve
// setting.
$this
->assertTrue($job
->isFinished());
$this
->assertEqual($item1
->getData(array(
'dummy',
'deep_nesting',
'#translation',
'#text',
)), $translation1);
$this
->assertEqual($item2
->getData(array(
'dummy',
'deep_nesting',
'#translation',
'#text',
)), $translation2);
// Delete the job, make sure that the corresponding task and task items were
// deleted.
$job
->delete();
$this
->assertEmpty(LocalTask::load($task
->id()));
$this
->assertEmpty($task
->getItems());
}
/**
* Test the allow all setting.
*/
public function testAllowAll() {
/** @var Translator $translator */
$translator = Translator::load('local');
// Create a job and request a local translation.
$this
->loginAsTranslator();
$job = $this
->createJob();
$job->translator = $translator
->id();
$job
->addItem('test_source', 'test', '1');
$job
->addItem('test_source', 'test', '2');
$this
->assertFalse($job
->requestTranslation(), 'Translation request was denied.');
// Now enable the setting.
$this
->config('tmgmt_local.settings')
->set('allow_all', TRUE)
->save();
/** @var Job $job */
$job = \Drupal::entityTypeManager()
->getStorage('tmgmt_job')
->loadUnchanged($job
->id());
$job->translator = $translator
->id();
$this
->assertIdentical(NULL, $job
->requestTranslation(), 'Translation request was successfull');
$this
->assertTrue($job
->isActive());
}
public function testAbilitiesAPI() {
$this
->addLanguage('fr');
$this
->addLanguage('ru');
$this
->addLanguage('it');
$all_assignees = array();
$assignee1 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$all_assignees[$assignee1
->id()] = $assignee1
->getDisplayName();
$this
->drupalLogin($assignee1);
$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'));
$assignee2 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$all_assignees[$assignee2
->id()] = $assignee2
->getDisplayName();
$this
->drupalLogin($assignee2);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'ru',
);
$this
->drupalPostForm('user/' . $assignee2
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[1][language_from]' => 'en',
'tmgmt_translation_skills[1][language_to]' => 'fr',
);
$this
->drupalPostForm('user/' . $assignee2
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[2][language_from]' => 'fr',
'tmgmt_translation_skills[2][language_to]' => 'it',
);
$this
->drupalPostForm('user/' . $assignee2
->id() . '/edit', $edit, t('Save'));
$assignee3 = $this
->drupalCreateUser($this->localTranslatorPermissions);
$all_assignees[$assignee3
->id()] = $assignee3
->getDisplayName();
$this
->drupalLogin($assignee3);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'fr',
'tmgmt_translation_skills[0][language_to]' => 'ru',
);
$this
->drupalPostForm('user/' . $assignee3
->id() . '/edit', $edit, t('Save'));
$edit = array(
'tmgmt_translation_skills[1][language_from]' => 'it',
'tmgmt_translation_skills[1][language_to]' => 'en',
);
$this
->drupalPostForm('user/' . $assignee3
->id() . '/edit', $edit, t('Save'));
// Test target languages.
$target_languages = tmgmt_local_supported_target_languages('fr');
$this
->assertTrue(isset($target_languages['it']));
$this
->assertTrue(isset($target_languages['ru']));
$target_languages = tmgmt_local_supported_target_languages('en');
$this
->assertTrue(isset($target_languages['fr']));
$this
->assertTrue(isset($target_languages['ru']));
// Test language pairs.
$this
->assertEqual(tmgmt_local_supported_language_pairs(), array(
'en__de' => array(
'source_language' => 'en',
'target_language' => 'de',
),
'en__ru' => array(
'source_language' => 'en',
'target_language' => 'ru',
),
'en__fr' => array(
'source_language' => 'en',
'target_language' => 'fr',
),
'fr__it' => array(
'source_language' => 'fr',
'target_language' => 'it',
),
'fr__ru' => array(
'source_language' => 'fr',
'target_language' => 'ru',
),
'it__en' => array(
'source_language' => 'it',
'target_language' => 'en',
),
));
$this
->assertEqual(tmgmt_local_supported_language_pairs('fr', array(
$assignee2
->id(),
)), array(
'fr__it' => array(
'source_language' => 'fr',
'target_language' => 'it',
),
));
// Test if we got all translators.
$assignees = tmgmt_local_assignees();
foreach ($all_assignees as $uid => $name) {
if (!isset($assignees[$uid])) {
$this
->fail('Expected translator not present');
}
if (!in_array($name, $all_assignees)) {
$this
->fail('Expected translator name not present');
}
}
// Only translator2 has such abilities.
$assignees = tmgmt_local_assignees('en', array(
'ru',
'fr',
));
$this
->assertTrue(isset($assignees[$assignee2
->id()]));
}
/**
* Test permissions for the tmgmt_local VBO actions.
*/
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(),
]));
}
/**
* Tests of the task progress.
*/
public function testLocalProgress() {
// Load the local translator.
$translator = Translator::load('local');
// Create assignee with the skills.
$assignee1 = $this
->drupalCreateUser($this->localManagerPermissions);
$this
->drupalLogin($assignee1);
$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'));
// Login as translator.
$this
->loginAsTranslator();
// Create the basic html format.
$basic_html_format = FilterFormat::create(array(
'format' => 'basic_html',
'name' => 'Basic HTML',
));
$basic_html_format
->save();
// Create a Job.
$job = $this
->createJob();
$job->translator = $translator
->id();
$item1 = $job
->addItem('test_source', 'test', '1');
\Drupal::state()
->set('tmgmt.test_source_data', array(
'title' => array(
'deep_nesting' => array(
'#text' => 'Example text',
'#label' => 'Label for job item with type test and id 2.',
'#translate' => TRUE,
),
),
'text' => array(
'deep_nesting' => array(
'#text' => 'Example text',
'#label' => 'Label for job item with type test and id 2.',
'#translate' => TRUE,
),
),
));
$job
->addItem('test_source', 'test', '2');
$job
->save();
$this
->drupalGet($job
->toUrl());
$this
->drupalPostForm(NULL, NULL, t('Submit to provider'));
// Login as assignee.
$this
->drupalLogin($assignee1);
// Check the task unassigned icon.
$this
->drupalGet('/manage-translate');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'unassigned', 'Unassigned');
// Assign the task and check its icon.
$edit = array(
'action' => 'tmgmt_local_task_assign_to_me',
'tmgmt_local_task_bulk_form[0]' => 1,
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'assigned', 'Needs action');
// Unassign it back.
$edit = array(
'action' => 'tmgmt_local_task_unassign_multiple',
'tmgmt_local_task_bulk_form[0]' => 1,
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Check its unassigned icon.
$this
->drupalGet('/manage-translate');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'unassigned', 'Unassigned');
$this
->drupalGet('/translate');
// Check the unassigned status.
$this
->assertTaskStatusIcon(1, 'task-overview', 'unassigned', 'Unassigned');
$edit = array(
'tmgmt_local_task_bulk_form[0]' => 1,
);
$this
->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Check the needs action status.
$this
->assertTaskStatusIcon(1, 'task-overview', 'my-tasks', 'Needs action');
// Check if the task is displayed on pending overview.
$this
->drupalGet('/translate/pending');
$this
->assertTaskStatusIcon(1, 'task-overview', 'pending', 'Needs action');
$this
->drupalGet('/manage-translate/pending');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'pending', 'Needs action');
// Check the icons of the task items.
$this
->drupalGet('/translate/1');
$this
->assertTaskItemStatusIcon('test_source:test:1', 'Untranslated');
$this
->assertTaskItemStatusIcon('test_source:test:2', 'Untranslated');
$this
->assertTaskItemProgress('test_source:test:1', 1, 0, 0);
$this
->assertTaskItemProgress('test_source:test:2', 2, 0, 0);
// Check the progress bar and status of the task.
$this
->drupalGet('/translate');
$this
->assertTaskProgress(1, 'my-tasks', 3, 0, 0);
$this
->assertTaskStatusIcon(1, 'task-overview', 'my-tasks', 'Needs action');
$this
->drupalGet('/manage-translate');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'assigned', 'Needs action');
// Set two items as translated.
$page = $this
->getSession()
->getPage();
$this
->drupalGet('translate/items/1');
$page
->pressButton('finish-dummy|deep_nesting');
$this
->drupalGet('translate/items/2');
$page
->pressButton('finish-title|deep_nesting');
// Check the task items icons and progress.
$this
->drupalGet('/translate/1');
$this
->assertTaskItemStatusIcon('test_source:test:1', 'Untranslated');
$this
->assertTaskItemStatusIcon('test_source:test:2', 'Untranslated');
$this
->assertTaskItemProgress('test_source:test:1', 0, 1, 0);
$this
->assertTaskItemProgress('test_source:test:2', 1, 1, 0);
// Check the progress bar and status of the task.
$this
->drupalGet('/translate');
$this
->assertTaskProgress(1, 'my-tasks', 1, 2, 0);
$this
->assertTaskStatusIcon(1, 'task-overview', 'my-tasks', 'Needs action');
$this
->drupalGet('/manage-translate');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'assigned', 'Needs action');
// Save the first item as completed and check item icons and progress.
$edit = [
'dummy|deep_nesting[translation]' => 'German translation',
];
$this
->drupalPostForm('/translate/items/1', $edit, t('Save as completed'));
$this
->assertTaskItemStatusIcon('test_source:test:1', 'Translated');
$this
->assertTaskItemStatusIcon('test_source:test:2', 'Untranslated');
$this
->assertTaskItemProgress('test_source:test:1', 0, 0, 1);
$this
->assertTaskItemProgress('test_source:test:2', 1, 1, 0);
// Check the progress bar and status of the task.
$this
->drupalGet('/translate');
$this
->assertTaskProgress(1, 'my-tasks', 1, 1, 1);
$this
->assertTaskStatusIcon(1, 'task-overview', 'my-tasks', 'Needs action');
$this
->drupalGet('/manage-translate');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'assigned', 'Needs action');
// Save the second item as completed.
$edit = [
'title|deep_nesting[translation]' => 'German translation of title',
'text|deep_nesting[translation]' => 'German translation of text',
];
$this
->drupalPostForm('/translate/items/2', $edit, t('Save as completed'));
// Check the icon a progress bar of the task.
$this
->assertTaskProgress(1, 'my-tasks', 0, 0, 3);
$this
->assertTaskStatusIcon(1, 'task-overview', 'my-tasks', 'In review');
// Check the task items icons.
$this
->drupalGet('/translate/1');
$this
->assertTaskItemStatusIcon('test_source:test:1', 'Translated');
$this
->assertTaskItemStatusIcon('test_source:test:2', 'Translated');
$this
->assertTaskItemProgress('test_source:test:1', 0, 0, 1);
$this
->assertTaskItemProgress('test_source:test:2', 0, 0, 2);
// Check if the task is displayed on the completed overview.
$this
->drupalGet('/translate/completed');
$this
->assertTaskStatusIcon(1, 'task-overview', 'completed', 'In review');
$this
->drupalGet('/manage-translate/completed');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'completed', 'In review');
// Accept translation of the job items.
/** @var \Drupal\tmgmt\Entity\Job $job1 */
$job1 = Job::load($job
->id());
/** @var \Drupal\tmgmt\Entity\JobItem $item */
foreach ($job1
->getItems() as $item) {
$item
->acceptTranslation();
}
// Check if the task is displayed on the closed overview.
$this
->drupalGet('/translate/closed');
$this
->assertTaskStatusIcon(1, 'task-overview', 'closed', 'Closed');
$this
->drupalGet('/manage-translate/closed');
$this
->assertTaskStatusIcon(1, 'manage-translate-task', 'closed', 'Closed');
// Assert the legend.
$this
->drupalGet('/translate/items/' . $item1
->id());
$this
->assertRaw('class="tmgmt-color-legend');
}
/**
* Test permissions for the tmgmt_local VBO actions.
*/
public function testUserPermissionsAccess() {
$permissions = [
'administer tmgmt',
'create translation jobs',
'accept translation jobs',
'administer translation tasks',
];
foreach ($permissions as $permission) {
$user = $this
->drupalCreateUser([
$permission,
]);
$this
->drupalLogin($user);
$this
->drupalGet('admin/tmgmt');
$this
->assertText('Translation');
}
$user = $this
->drupalCreateUser([
'provide translation services',
]);
$this
->drupalLogin($user);
$this
->drupalGet('admin/tmgmt');
$this
->assertText('Local Tasks');
}
/**
* Test the settings of TMGMT local.
*/
public function testSettings() {
\Drupal::getContainer()
->get('theme_installer')
->install([
'seven',
]);
$this
->drupalPlaceBlock('system_menu_block:account');
$this
->loginAsAdmin($this->localManagerPermissions);
$edit = [
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
];
$this
->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$settings = \Drupal::config('tmgmt_local.settings');
$this
->assertTrue($settings
->get('use_admin_theme'));
$this
->drupalGet('admin/tmgmt');
$this
->assertText('Translate');
$this
->drupalGet('<front>');
$this
->assertNoText('Translate');
$this
->drupalGet('admin/tmgmt/settings');
$edit = [
'use_admin_theme' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$settings = \Drupal::config('tmgmt_local.settings');
$this
->assertFalse($settings
->get('use_admin_theme'));
$this
->drupalGet('admin/tmgmt');
$this
->assertNoText('Translate');
$this
->drupalGet('<front>');
$this
->assertText('Translate');
}
/**
* Test the task and task items are closed and completed when aborting a Job.
*/
public function testAbort() {
// Prepare the scenario.
$translator = Translator::load('local');
$this
->loginAsTranslator($this->localTranslatorPermissions);
$edit = array(
'tmgmt_translation_skills[0][language_from]' => 'en',
'tmgmt_translation_skills[0][language_to]' => 'de',
);
$this
->drupalPostForm('user/' . $this->translator_user
->id() . '/edit', $edit, t('Save'));
$job = $this
->createJob();
$job->translator = $translator
->id();
$first_job_item = $job
->addItem('test_source', 'test', '1');
\Drupal::state()
->set('tmgmt.test_source_data', [
'dummy' => [
'deep_nesting' => [
'#text' => file_get_contents(drupal_get_path('module', 'tmgmt') . '/tests/testing_html/sample.html'),
'#label' => 'Label for job item with type test and id 2.',
'#translate' => TRUE,
'#format' => 'basic_html',
],
],
]);
$second_job_item = $job
->addItem('test_source', 'test', '2');
$job
->save();
$edit = [
'settings[translator]' => $this->translator_user
->id(),
];
$this
->drupalPostForm($job
->toUrl(), $edit, t('Submit to provider'));
// Check Job Item abort, close the task item.
$this
->drupalGet('admin/tmgmt/items/' . $first_job_item
->id() . '/abort');
$this
->drupalPostForm(NULL, [], t('Confirm'));
$this
->drupalGet('translate');
$this
->assertNoRaw('views-field-progress">Closed');
$this
->clickLink(t('View'));
$this
->assertRaw('views-field-progress">Closed');
$this
->assertNotEmpty(preg_match('|translate/(\\d+)|', $this
->getUrl(), $matches), 'Task found');
/** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->load($matches[1]);
$this
->assertTrue($task
->isPending());
// Checking if the 'Save as completed' button is not displayed.
$this
->drupalGet('translate/items/1');
$elements = $this
->xpath('//*[@id="edit-save-as-completed"]');
$this
->assertTrue(empty($elements), "'Save as completed' button does not appear.");
// Checking if the 'Save' button is not displayed.
$elements = $this
->xpath('//*[@id="edit-save"]');
$this
->assertTrue(empty($elements), "'Save' button does not appear.");
// Checking if the 'Preview' button is not displayed.
$elements = $this
->xpath('//*[@id="edit-preview"]');
$this
->assertTrue(empty($elements), "'Preview' button does not appear.");
// Checking if the '✓' button is not displayed.
$elements = $this
->xpath('//*[@id="edit-dummydeep-nesting-actions-finish-dummydeep-nesting"]');
$this
->assertTrue(empty($elements), "'✓' button does not appear.");
// Checking translation is readonly.
$this
->assertRaw('data-drupal-selector="edit-dummydeep-nesting-translation" readonly="readonly"');
// Check closing all task items also closes the task.
$this
->drupalGet('admin/tmgmt/items/' . $second_job_item
->id() . '/abort');
$this
->drupalPostForm(NULL, [], t('Confirm'));
$this
->drupalGet('translate/closed');
$this
->assertText($task
->label());
$task = \Drupal::entityTypeManager()
->getStorage('tmgmt_local_task')
->loadUnchanged($matches[1]);
$this
->assertTrue($task
->isClosed());
$this
->assertRaw('views-field-progress">Closed');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was present in the last response. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is not present. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is present. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertLegacyTrait:: |
protected | function | Checks that current response header equals value. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was absent in the last response. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text is not found escaped on the loaded page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does NOT exist with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option does NOT exist in the current page. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is not found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS not found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Asserts the page responds with the specified response code. | 1 |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertLegacyTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Passes if the internal browser's URL matches the given path. | |
AssertLegacyTrait:: |
protected | function | Builds an XPath query. | |
AssertLegacyTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertLegacyTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertLegacyTrait:: |
protected | function | Gets the current raw content. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
BlockCreationTrait:: |
protected | function | Creates a block instance based on default settings. Aliased as: drupalPlaceBlock | |
BrowserHtmlDebugTrait:: |
protected | property | The Base URI to use for links to the output files. | |
BrowserHtmlDebugTrait:: |
protected | property | Class name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter storage for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Directory name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output output enabled. | |
BrowserHtmlDebugTrait:: |
protected | property | The file name to write the list of URLs to. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output test ID. | |
BrowserHtmlDebugTrait:: |
protected | function | Formats HTTP headers as string for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | function | Returns headers in HTML output format. | 1 |
BrowserHtmlDebugTrait:: |
protected | function | Logs a HTML output message in a text file. | |
BrowserHtmlDebugTrait:: |
protected | function | Creates the directory to store browser output. | |
BrowserTestBase:: |
protected | property | The base URL. | |
BrowserTestBase:: |
protected | property | The config importer that can be used in a test. | |
BrowserTestBase:: |
protected | property | An array of custom translations suitable for drupal_rewrite_settings(). | |
BrowserTestBase:: |
protected | property | The database prefix of this test run. | |
BrowserTestBase:: |
protected | property | Mink session manager. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | 1 | |
BrowserTestBase:: |
protected | property | The original container. | |
BrowserTestBase:: |
protected | property | The original array of shutdown function callbacks. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | The profile to install as a basis for testing. | 39 |
BrowserTestBase:: |
protected | property | The app root. | |
BrowserTestBase:: |
protected | property | Browser tests are run in separate processes to prevent collisions between code that may be loaded by tests. | |
BrowserTestBase:: |
protected | property | Time limit in seconds for the test. | |
BrowserTestBase:: |
protected | property | The translation file directory for the test environment. | |
BrowserTestBase:: |
protected | function | Clean up the Simpletest environment. | |
BrowserTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
BrowserTestBase:: |
protected | function | Translates a CSS expression to its XPath equivalent. | |
BrowserTestBase:: |
protected | function | Gets the value of an HTTP response header. | |
BrowserTestBase:: |
protected | function | Returns all response headers. | |
BrowserTestBase:: |
public static | function | Ensures test files are deletable. | |
BrowserTestBase:: |
protected | function | Gets an instance of the default Mink driver. | |
BrowserTestBase:: |
protected | function | Gets the JavaScript drupalSettings variable for the currently-loaded page. | 1 |
BrowserTestBase:: |
protected | function | Obtain the HTTP client for the system under test. | |
BrowserTestBase:: |
protected | function | Get the Mink driver args from an environment variable, if it is set. Can be overridden in a derived class so it is possible to use a different value for a subset of tests, e.g. the JavaScript tests. | 1 |
BrowserTestBase:: |
protected | function | Helper function to get the options of select field. | |
BrowserTestBase:: |
protected | function |
Provides a Guzzle middleware handler to log every response received. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
public | function | Returns Mink session. | |
BrowserTestBase:: |
protected | function | Get session cookies from current session. | |
BrowserTestBase:: |
protected | function |
Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
protected | function | Visits the front page when initializing Mink. | 3 |
BrowserTestBase:: |
protected | function | Initializes Mink sessions. | 1 |
BrowserTestBase:: |
public | function | Installs Drupal into the Simpletest site. | 1 |
BrowserTestBase:: |
protected | function | Registers additional Mink sessions. | |
BrowserTestBase:: |
protected | function | 3 | |
BrowserTestBase:: |
protected | function | Transforms a nested array into a flat array suitable for drupalPostForm(). | |
BrowserTestBase:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
BrowserTestBase:: |
public | function | 1 | |
BrowserTestBase:: |
public | function | Prevents serializing any properties. | |
CommentTestTrait:: |
public | function | Adds the default comment field to an entity. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. Aliased as: drupalCreateContentType | 1 |
FunctionalTestSetupTrait:: |
protected | property | The flag to set 'apcu_ensure_unique_prefix' setting. | 1 |
FunctionalTestSetupTrait:: |
protected | property | The class loader to use for installation and initialization of setup. | |
FunctionalTestSetupTrait:: |
protected | property | The config directories used in this test. | |
FunctionalTestSetupTrait:: |
protected | property | The "#1" admin user. | |
FunctionalTestSetupTrait:: |
protected | function | Execute the non-interactive installer. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns all supported database driver installer objects. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize various configurations post-installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Initializes the kernel after installation. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize settings created during install. | |
FunctionalTestSetupTrait:: |
protected | function | Initializes user 1 for the site to be installed. | |
FunctionalTestSetupTrait:: |
protected | function | Installs the default theme defined by `static::$defaultTheme` when needed. | |
FunctionalTestSetupTrait:: |
protected | function | Install modules defined by `static::$modules`. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns the parameters that will be used when Simpletest installs Drupal. | 9 |
FunctionalTestSetupTrait:: |
protected | function | Prepares the current environment for running the test. | 23 |
FunctionalTestSetupTrait:: |
protected | function | Creates a mock request and sets it on the generator. | |
FunctionalTestSetupTrait:: |
protected | function | Prepares site settings and services before installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Resets and rebuilds the environment after setup. | |
FunctionalTestSetupTrait:: |
protected | function | Rebuilds \Drupal::getContainer(). | |
FunctionalTestSetupTrait:: |
protected | function | Resets all data structures after having enabled new modules. | |
FunctionalTestSetupTrait:: |
protected | function | Changes parameters in the services.yml file. | |
FunctionalTestSetupTrait:: |
protected | function | Sets up the base URL based upon the environment variable. | |
FunctionalTestSetupTrait:: |
protected | function | Rewrites the settings.php file of the test site. | |
LocalTranslatorTest:: |
public | function | ||
LocalTranslatorTest:: |
public | function | Test the task and task items are closed and completed when aborting a Job. | |
LocalTranslatorTest:: |
public | function | Test the allow all setting. | |
LocalTranslatorTest:: |
public | function | Test assignee skills. | |
LocalTranslatorTest:: |
public | function | Test the basic translation workflow. | |
LocalTranslatorTest:: |
public | function | Tests of the task progress. | |
LocalTranslatorTest:: |
public | function | Test the settings of TMGMT local. | |
LocalTranslatorTest:: |
public | function | Test permissions for the tmgmt_local VBO actions. | |
LocalTranslatorTest:: |
public | function | Test permissions for the tmgmt_local VBO actions. | |
LocalTranslatorTestBase:: |
protected | property | Translator user. | |
LocalTranslatorTestBase:: |
protected | property | ||
LocalTranslatorTestBase:: |
protected | property | ||
LocalTranslatorTestBase:: |
public static | property |
Modules to enable. Overrides TMGMTTestBase:: |
2 |
LocalTranslatorTestBase:: |
protected | function | Asserts the task item progress bar. | |
LocalTranslatorTestBase:: |
protected | function | Asserts task item status icon. | |
LocalTranslatorTestBase:: |
protected | function | Asserts the task progress bar. | |
LocalTranslatorTestBase:: |
protected | function | Asserts task status icon. | |
LocalTranslatorTestBase:: |
public | function |
Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase:: |
|
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. Aliased as: drupalCreateNode | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
RefreshVariablesTrait:: |
protected | function | Refreshes in-memory configuration and state information. | 3 |
SessionTestTrait:: |
protected | property | The name of the session cookie. | |
SessionTestTrait:: |
protected | function | Generates a session cookie name. | |
SessionTestTrait:: |
protected | function | Returns the session name in use on the child site. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
TestSetupTrait:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
TestSetupTrait:: |
protected | property | The dependency injection container used in the test. | |
TestSetupTrait:: |
protected | property | The DrupalKernel instance used in the test. | |
TestSetupTrait:: |
protected | property | The site directory of the original parent site. | |
TestSetupTrait:: |
protected | property | The private file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The public file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The site directory of this test run. | |
TestSetupTrait:: |
protected | property | Set to TRUE to strict check all configuration saved. | 2 |
TestSetupTrait:: |
protected | property | The temporary file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The test run ID. | |
TestSetupTrait:: |
protected | function | Changes the database connection to the prefixed one. | |
TestSetupTrait:: |
protected | function | Gets the config schema exclusions for this test. | |
TestSetupTrait:: |
public static | function | Returns the database connection to the site running Simpletest. | |
TestSetupTrait:: |
protected | function | Generates a database prefix for running tests. | 2 |
TmgmtEntityTestTrait:: |
public | property | ||
TmgmtEntityTestTrait:: |
function | Creates fields of type text and text_with_summary of different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates node type with several text fields with different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates a taxonomy term of a given vocabulary. | ||
TmgmtEntityTestTrait:: |
function | Creates taxonomy vocabulary with custom fields. | ||
TmgmtEntityTestTrait:: |
protected | function | Creates a node of a given bundle. | |
TMGMTTestBase:: |
protected | property |
The theme to install as the default for testing. Overrides BrowserTestBase:: |
|
TMGMTTestBase:: |
protected | property | A default translator using the test translator. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | The language weight for new languages. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsTranslator(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsTranslator(). | |
TmgmtTestTrait:: |
function | Sets the proper environment. | ||
TmgmtTestTrait:: |
function | Asserts job item language codes. | ||
TmgmtTestTrait:: |
protected | function | Asserts text in the page with an xpath expression. | |
TmgmtTestTrait:: |
function | Clicks on an image link with the provided title attribute. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translation job. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translator. | ||
TmgmtTestTrait:: |
function | Will create a user with admin permissions and log it in. | ||
TmgmtTestTrait:: |
function | Will create a user with translator permissions and log it in. | ||
UiHelperTrait:: |
protected | property | The current user logged in using the Mink controlled browser. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects to follow, or NULL if unlimited. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects followed during ::drupalGet(). | |
UiHelperTrait:: |
public | function | Returns WebAssert object. | 1 |
UiHelperTrait:: |
protected | function | Builds an a absolute URL from a system path or a URL object. | |
UiHelperTrait:: |
protected | function | Checks for meta refresh tag and if found call drupalGet() recursively. | |
UiHelperTrait:: |
protected | function | Clicks the element with the given CSS selector. | |
UiHelperTrait:: |
protected | function | Follows a link by complete name. | |
UiHelperTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
UiHelperTrait:: |
protected | function | Retrieves a Drupal path or an absolute path. | 3 |
UiHelperTrait:: |
protected | function | Logs in a user using the Mink controlled browser. | |
UiHelperTrait:: |
protected | function | Logs a user out of the Mink controlled browser and confirms. | |
UiHelperTrait:: |
protected | function | Executes a form submission. | |
UiHelperTrait:: |
protected | function | Returns whether a given user account is logged in. | |
UiHelperTrait:: |
protected | function | Takes a path and returns an absolute path. | |
UiHelperTrait:: |
protected | function | Retrieves the plain-text content from the current page. | |
UiHelperTrait:: |
protected | function | Get the current URL from the browser. | |
UiHelperTrait:: |
protected | function | Prepare for a request to testing site. | 1 |
UiHelperTrait:: |
protected | function | Fills and submits a form. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
XdebugRequestTrait:: |
protected | function | Adds xdebug cookies, from request setup. |