Test for simple configuration translation.
function testSimpleConfigTranslation() {
$this
->loginAsTranslator(array(
'translate configuration',
));
// Go to the translate tab.
$this
->drupalGet('admin/tmgmt/sources/config/_simple_config');
// Assert some basic strings on that page.
$this
->assertSession()
->pageTextContains('Simple configuration overview (Config Entity)');
// Request a translation for Site information settings.
$edit = array(
'items[system.site_information_settings]' => TRUE,
);
$this
->submitForm($edit, 'Request translation');
// Verify that we are on the translate tab.
$this
->assertSession()
->pageTextContains('One job needs to be checked out.');
$this
->assertSession()
->pageTextContains('System information (English to ?, Unprocessed)');
// Submit.
$this
->submitForm([], 'Submit to provider');
// Make sure that we're back on the originally defined destination URL.
$this
->assertSession()
->addressEquals('admin/tmgmt/sources/config/_simple_config');
$overview_url = Url::fromRoute('tmgmt.source_overview', array(
'plugin' => 'config',
'item_type' => '_simple_config',
))
->toString();
// Translated languages should now be listed as Needs review.
$url = JobItem::load(1)
->toUrl()
->setOption('query', [
'destination' => $overview_url,
])
->toString();
$imgs = $this
->xpath('//a[@href=:href]/img', [
':href' => $url,
]);
$this
->assertEquals('Active job item: Needs review', $imgs[0]
->getAttribute('title'));
$this
->assertSession()
->pageTextContains('Test translation created.');
$this
->assertSession()
->pageTextContains('The translation of System information to German is finished and can now be reviewed.');
// Verify that the pending translation is shown.
$review = $this
->xpath('//table[@id="edit-items"]/tbody/tr[@class="even"][1]/td[@class="langstatus-de"]/a');
$destination = $this
->getAbsoluteUrl($review[0]
->getAttribute('href'));
$this
->drupalGet($destination);
$this
->submitForm([], 'Save');
// Request a translation for Account settings
$edit = array(
'items[entity.user.admin_form]' => TRUE,
);
$this
->submitForm($edit, 'Request translation');
// Verify that we are on the checkout page.
$this
->assertSession()
->pageTextContains('One job needs to be checked out.');
$this
->assertSession()
->pageTextContains('Account settings (English to ?, Unprocessed)');
$this
->submitForm([], 'Submit to provider');
// Make sure that we're back on the originally defined destination URL.
$this
->assertSession()
->addressEquals('admin/tmgmt/sources/config/_simple_config');
// Translated languages should now be listed as Needs review.
$links = $this
->xpath('//table[@id="edit-items"]/tbody/tr/td/a');
$this
->assertEquals(2, count($links));
// Save one translation.
$this
->drupalGet('admin/tmgmt/items/1');
$this
->submitForm([], 'Save as completed');
// Test if the filter works.
$this
->drupalGet('admin/tmgmt/sources/config/_simple_config');
$filters = array(
'search[name]' => 'system',
);
$this
->submitForm($filters, 'Search');
// Check if the list has 2 rows.
$this
->assertCount(2, $this
->xpath('//tbody/tr'));
$this
->drupalGet('admin/tmgmt/sources/config/_simple_config');
$filters = array(
'search[target_language]' => 'de',
'search[target_status]' => 'translated',
);
$this
->submitForm($filters, 'Search');
// Just 1 simple configuration was translated.
$this
->assertCount(1, $this
->xpath('//tbody/tr'));
// Filter with name and target_status.
$this
->drupalGet('admin/tmgmt/sources/config/_simple_config');
$filters = array(
'search[name]' => 'settings',
'search[target_language]' => 'de',
'search[target_status]' => 'untranslated',
);
$this
->submitForm($filters, 'Search');
// There is 1 simple configuration untranslated with name 'settings'.
$this
->assertCount(1, $this
->xpath('//tbody/tr'));
$this
->drupalGet('admin/tmgmt/sources/config/_simple_config');
$filters = array(
'search[name]' => 'sys',
'search[target_language]' => 'de',
'search[target_status]' => 'translated',
);
$this
->submitForm($filters, 'Search');
// There are 2 simple configurations with name 'sys' but just 1 is translated.
$this
->assertCount(1, $this
->xpath('//tbody/tr'));
}