function ContentTranslationSettingsTest::testFieldTranslatableSettingsUI in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php \Drupal\content_translation\Tests\ContentTranslationSettingsTest::testFieldTranslatableSettingsUI()
Tests that field setting depends on bundle translatability.
File
- core/
modules/ content_translation/ src/ Tests/ ContentTranslationSettingsTest.php, line 253 - Contains \Drupal\content_translation\Tests\ContentTranslationSettingsTest.
Class
- ContentTranslationSettingsTest
- Tests the content translation settings UI.
Namespace
Drupal\content_translation\TestsCode
function testFieldTranslatableSettingsUI() {
// At least one field needs to be translatable to enable article for
// translation. Create an extra field to be used for this purpose. We use
// the UI to test our form alterations.
$edit = array(
'new_storage_type' => 'text',
'label' => 'Test',
'field_name' => 'article_text',
);
$this
->drupalPostForm('admin/structure/types/manage/article/fields/add-field', $edit, 'Save and continue');
// Tests that field doesn't have translatable setting if bundle is not
// translatable.
$path = 'admin/structure/types/manage/article/fields/node.article.field_article_text';
$this
->drupalGet($path);
$this
->assertFieldByXPath('//input[@id="edit-translatable" and @disabled="disabled"]');
$this
->assertText('To configure translation for this field, enable language support for this type.', 'No translatable setting for field.');
// Tests that field has translatable setting if bundle is translatable.
// Note: this field is not translatable when enable bundle translatability.
$edit = array(
'entity_types[node]' => TRUE,
'settings[node][article][settings][language][language_alterable]' => TRUE,
'settings[node][article][translatable]' => TRUE,
'settings[node][article][fields][field_article_text]' => TRUE,
);
$this
->assertSettings('node', 'article', TRUE, $edit);
$this
->drupalGet($path);
$this
->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]');
$this
->assertNoText('To enable translation of this field, enable language support for this type.', 'Translatable setting for field available.');
}