function ConfigTranslationOverviewTest::testMapperListPage
Same name in other branches
- 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationOverviewTest::testMapperListPage()
- 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationOverviewTest::testMapperListPage()
- 11.x core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationOverviewTest::testMapperListPage()
Tests the config translation mapper page.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationOverviewTest.php, line 86
Class
- ConfigTranslationOverviewTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testMapperListPage() {
$this->drupalGet('admin/config/regional/config-translation');
$this->assertSession()
->linkByHrefExists('admin/config/regional/config-translation/config_test');
$this->assertSession()
->linkByHrefExists('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->assertCount(1, $dropbutton->findAll('xpath', 'li'));
$this->assertTrue($dropbutton->getText() === 'Translate' || $dropbutton->getText() === 'List');
}
$labels = [
'&$nxd~i0',
'some "label" with quotes',
$this->randomString(),
];
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
foreach ($labels as $label) {
$test_entity = $storage->create([
'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->assertSession()
->linkByHrefExists($base_url . '/translate');
$this->assertSession()
->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->assertCount(1, $dropbutton->findAll('xpath', 'li'));
$this->assertSame('Translate', $dropbutton->getText());
}
$entity_type = \Drupal::entityTypeManager()->getDefinition($test_entity->getEntityTypeId());
$this->drupalGet($base_url . '/translate');
$title = $test_entity->label() . ' ' . $entity_type->getSingularLabel();
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
$this->assertSession()
->responseContains($title);
$this->assertSession()
->responseContains('<th>Language</th>');
$this->drupalGet($base_url);
$this->assertSession()
->linkExists('Translate test configuration');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.