1.20.x text.test | TextTranslationTestCase::testTextFieldFormatted() |
Check that user that does not have access the field format cannot see the source value when creating a translation.
File
- modules/
field/ modules/ text/ tests/ text.test, line 451 - Tests for text.module.
Class
Code
function testTextFieldFormatted() {
// Make node body multiple.
$edit = array('field[cardinality]' => -1);
$this->backdropPost('admin/structure/types/manage/post/fields/body', $edit, t('Save settings'));
$this->backdropGet('node/add/post');
$this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), 'Body field cardinality set to multiple.');
$body = array(
$this->randomName(),
$this->randomName(),
);
// Create an post with the first body input format set to "Raw HTML"
// (full_html).
$title = $this->randomName();
$edit = array(
'title' => $title,
'langcode' => 'en',
);
$this->backdropPost('node/add/post', $edit, t('Save'));
$node = $this->backdropGetNodeByTitle($title);
// Populate the body field: the first item gets the "Raw HTML" (full_html)
// input format, the second one "Filtered HTML".
$formats = array('full_html', 'filtered_html');
$langcode = LANGUAGE_NONE;
foreach ($body as $delta => $value) {
$edit = array(
"body[$langcode][$delta][value]" => $value,
"body[$langcode][$delta][format]" => array_shift($formats),
);
$this->backdropPost("node/$node->nid/edit", $edit, t('Save'));
$this->assertText($body[$delta], format_string('The body field with delta @delta has been saved.', array('@delta' => $delta)));
}
// Login as translator.
$this->backdropLogin($this->translator);
// Translate the post in french.
$this->backdropGet("node/$node->nid/translate");
$this->clickLink(t('Add translation'));
$this->assertNoText($body[0], format_string('The body field with delta @delta is hidden.', array('@delta' => 0)));
$this->assertText($body[1], format_string('The body field with delta @delta is shown.', array('@delta' => 1)));
}