public function NodeTypeTranslationTest::testNodeTypeTitleLabelTranslation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Tests/NodeTypeTranslationTest.php \Drupal\node\Tests\NodeTypeTranslationTest::testNodeTypeTitleLabelTranslation()
Tests the node type title label translation.
File
- core/
modules/ node/ src/ Tests/ NodeTypeTranslationTest.php, line 119 - Contains \Drupal\node\Tests\NodeTypeTranslationTest.
Class
- NodeTypeTranslationTest
- Ensures that node types translation work correctly.
Namespace
Drupal\node\TestsCode
public function testNodeTypeTitleLabelTranslation() {
$type = Unicode::strtolower($this
->randomMachineName(16));
$name = $this
->randomString();
$this
->drupalLogin($this->adminUser);
$this
->drupalCreateContentType(array(
'type' => $type,
'name' => $name,
));
$langcode = $this->additionalLangcodes[0];
// Edit the title label for it to be displayed on the translation form.
$this
->drupalPostForm("admin/structure/types/manage/{$type}", array(
'title_label' => 'Edited title',
), t('Save content type'));
// Assert that the title label is displayed on the translation form with the right value.
$this
->drupalGet("admin/structure/types/manage/{$type}/translate/{$langcode}/add");
$this
->assertRaw(t('Label'));
$this
->assertRaw(t('Edited title'));
// Translate the title label.
$this
->drupalPostForm(NULL, array(
"translation[config_names][core.base_field_override.node.{$type}.title][label]" => 'Translated title',
), t('Save translation'));
// Assert that the right title label is displayed on the node add form.
$this
->drupalGet("node/add/{$type}");
$this
->assertRaw(t('Edited title'));
$this
->drupalGet("{$langcode}/node/add/{$type}");
$this
->assertRaw(t('Translated title'));
}