function TMGMTI18nStringSourceTestCase::testI18nStringPluginUIField in Translation Management Tool 7
Tests translation of fields through the user interface.
File
- sources/
i18n_string/ tmgmt_i18n_string.test, line 387
Class
- TMGMTI18nStringSourceTestCase
- Basic i18n String Source tests.
Code
function testI18nStringPluginUIField() {
$this
->loginAsAdmin(array(
'translate interface',
'translate user-defined strings',
));
$type = $this
->drupalCreateContentType(array(
'type' => $type = $this
->randomName(),
));
// Create a field.
$field = array(
'field_name' => 'list_test',
'type' => 'list_text',
);
for ($i = 0; $i < 5; $i++) {
$field['settings']['allowed_values'][$this
->randomName()] = $this
->randomString();
}
field_create_field($field);
// Create an instance of the previously created field.
$instance = array(
'field_name' => 'list_test',
'entity_type' => 'node',
'bundle' => $type->type,
'label' => $this
->randomName(10),
'description' => $this
->randomString(30),
);
field_create_instance($instance);
// The body field doesn't have anything that can be translated on the field
// level, so it shouldn't show up in the field overview.
$this
->drupalGet('admin/tmgmt/sources/i18n_string_field');
$this
->assertNoText(t('Body'));
// @todo: Label doesn't work here?
$this
->assertText('field:list_test:#allowed_values');
$this
->drupalGet('admin/tmgmt/sources/i18n_string_field_instance');
$this
->assertUniqueText(t('Body'));
$this
->assertUniqueText($instance['label']);
// Request translation.
$edit = array(
'items[field:body:' . $type->type . ']' => 1,
'items[field:list_test:' . $type->type . ']' => 1,
);
$this
->drupalPost(NULL, $edit, t('Request translation'));
$this
->assertText(t('Body'));
$this
->assertText($instance['label']);
$this
->drupalPost(NULL, array(), t('Submit to translator'));
$this
->assertRaw(t('Active job item: Needs review'));
// Review the first item.
$this
->clickLink(t('reviewed'));
$this
->drupalPost(NULL, array(), t('Save as completed'));
// The overview should now have a translated field and a pending job item.
$this
->drupalGet('admin/tmgmt/sources/i18n_string_field_instance');
$this
->assertRaw(t('Translation up to date'));
$this
->assertRaw(t('Active job item: Needs review'));
}