public function ConfigTranslationOverviewTest::testMapperListPage in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php \Drupal\config_translation\Tests\ConfigTranslationOverviewTest::testMapperListPage()
Tests the config translation mapper page.
File
- core/
modules/ config_translation/ src/ Tests/ ConfigTranslationOverviewTest.php, line 78 - Contains \Drupal\config_translation\Tests\ConfigTranslationOverviewTest.
Class
- ConfigTranslationOverviewTest
- Translate settings and entities to various languages.
Namespace
Drupal\config_translation\TestsCode
public function testMapperListPage() {
$this
->drupalGet('admin/config/regional/config-translation');
$this
->assertLinkByHref('admin/config/regional/config-translation/config_test');
$this
->assertLinkByHref('admin/config/people/accounts/translate');
// Make sure there is only a single operation for each dropbutton, either
// 'List' or 'Translate'.
foreach ($this
->cssSelect('ul.dropbutton') as $i => $dropbutton) {
$this
->assertIdentical(1, $dropbutton
->count());
foreach ($dropbutton->li as $link) {
$this
->assertTrue((string) $link->a === 'Translate' || (string) $link->a === 'List');
}
}
$labels = array(
'&$nxd~i0',
'some "label" with quotes',
$this
->randomString(),
);
foreach ($labels as $label) {
$test_entity = entity_create('config_test', array(
'id' => $this
->randomMachineName(),
'label' => $label,
));
$test_entity
->save();
$base_url = 'admin/structure/config_test/manage/' . $test_entity
->id();
$this
->drupalGet('admin/config/regional/config-translation/config_test');
$this
->assertLinkByHref($base_url . '/translate');
$this
->assertEscaped($test_entity
->label());
// Make sure there is only a single 'Translate' operation for each
// dropbutton.
foreach ($this
->cssSelect('ul.dropbutton') as $i => $dropbutton) {
$this
->assertIdentical(1, $dropbutton
->count());
foreach ($dropbutton->li as $link) {
$this
->assertIdentical('Translate', (string) $link->a);
}
}
$entity_type = \Drupal::entityManager()
->getDefinition($test_entity
->getEntityTypeId());
$this
->drupalGet($base_url . '/translate');
$title = $test_entity
->label() . ' ' . $entity_type
->getLowercaseLabel();
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
$this
->assertRaw($title);
$this
->assertRaw('<th>' . t('Language') . '</th>');
$this
->drupalGet($base_url);
$this
->assertLink(t('Translate @title', array(
'@title' => $entity_type
->getLowercaseLabel(),
)));
}
}