public function TMGMTDemoTest::testInstalled in Translation Management Tool 8
Asserts translation jobs can be created.
File
- modules/
demo/ tests/ src/ Functional/ TMGMTDemoTest.php, line 52
Class
- TMGMTDemoTest
- Tests the demo module for TMGMT.
Namespace
Drupal\Tests\tmgmt_demo\FunctionalCode
public function testInstalled() {
// Try and translate node 1.
$this
->drupalGet('node');
$this
->assertText('First node');
$this
->assertText('Second node');
$this
->assertText('TMGMT Demo');
$this
->clickLink(t('First node'));
$this
->clickLink(t('Translate'));
$edit = [
'languages[de]' => TRUE,
'languages[fr]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
$this
->assertText(t('2 jobs need to be checked out.'));
// Try and translate node 2.
$this
->drupalGet('admin/content');
$this
->clickLink(t('Second node'));
$this
->clickLink(t('Translate'));
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
$this
->assertText(t('2 jobs need to be checked out.'));
// Test local translator.
$edit = [
'translator' => 'local',
];
$this
->drupalPostForm(NULL, $edit, 'Submit to provider and continue');
$this
->assertText('The translation job has been submitted.');
// Check to see if no items are selected and the error message pops up.
$this
->drupalPostForm('admin/tmgmt/sources', [], t('Request translation'));
$this
->assertUniqueText(t("You didn't select any source items."));
$this
->drupalPostForm(NULL, [], t('Search'));
$this
->assertNoText(t("You didn't select any source items."));
$this
->drupalPostForm(NULL, [], t('Cancel'));
$this
->assertNoText(t("You didn't select any source items."));
$this
->drupalPostForm(NULL, [], t('Add to cart'));
$this
->assertUniqueText(t("You didn't select any source items."));
// Test if the formats are set properly.
$this
->drupalGet('node/1/edit');
$this
->assertOptionSelected('edit-body-0-format--2', 'basic_html', 'Basic HTML selected as format');
$this
->drupalGet('node/2/edit');
$this
->assertOptionSelected('edit-body-0-format--2', 'restricted_html', 'Restricted HTML selected as format');
$this
->drupalGet('node/3/edit');
$this
->assertOptionSelected('edit-body-0-format--2', 'full_html', 'Full HTML selected as format');
}