Tests that the settings UI works as expected.
function testSettingsUI() {
// Test that the translation settings are ignored if the bundle is marked
// translatable but the entity type is not.
$edit = array(
'settings[comment][comment_node_article][translatable]' => TRUE,
);
$this
->assertSettings('comment', NULL, FALSE, $edit);
// Test that the translation settings are ignored if only a field is marked
// as translatable and not the related entity type and bundle.
$edit = array(
'settings[comment][comment_node_article][fields][comment_body]' => TRUE,
);
$this
->assertSettings('comment', NULL, FALSE, $edit);
// Test that the translation settings are not stored if an entity type and
// bundle are marked as translatable but no field is.
$edit = array(
'entity_types[comment]' => TRUE,
'settings[comment][comment_node_article][translatable]' => TRUE,
);
$this
->assertSettings('comment', 'comment_node_article', FALSE, $edit);
$xpath_err = '//div[@id="messages"]//div[contains(@class, "error")]';
$this
->assertTrue($this
->xpath($xpath_err), 'Enabling translation only for entity bundles generates a form error.');
// Test that the translation settings are not stored if a non-configurable
// language is set as default and the language selector is hidden.
$edit = array(
'entity_types[comment]' => TRUE,
'settings[comment][comment_node_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED,
'settings[comment][comment_node_article][settings][language][language_show]' => FALSE,
'settings[comment][comment_node_article][translatable]' => TRUE,
'settings[comment][comment_node_article][fields][comment_body]' => TRUE,
);
$this
->assertSettings('comment', 'comment_node_article', FALSE, $edit);
$this
->assertTrue($this
->xpath($xpath_err), 'Enabling translation with a fixed non-configurable language generates a form error.');
// Test that a field shared among different bundles can be enabled without
// needing to make all the related bundles translatable.
$edit = array(
'entity_types[comment]' => TRUE,
'settings[comment][comment_node_article][settings][language][langcode]' => 'current_interface',
'settings[comment][comment_node_article][settings][language][language_show]' => TRUE,
'settings[comment][comment_node_article][translatable]' => TRUE,
'settings[comment][comment_node_article][fields][comment_body]' => TRUE,
);
$this
->assertSettings('comment', 'comment_node_article', TRUE, $edit);
field_info_cache_clear();
$field = field_info_field('comment_body');
$this
->assertTrue($field['translatable'], 'Comment body is translatable.');
// Test that language settings are correctly stored.
$language_configuration = language_get_default_configuration('comment', 'comment_node_article');
$this
->assertEqual($language_configuration['langcode'], 'current_interface', 'The default language for article comments is set to the current interface language.');
$this
->assertTrue($language_configuration['language_show'], 'The language selector for article comments is shown.');
}