diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/field/modules/text/text.module | 12 | ||||
-rw-r--r-- | modules/field/modules/text/text.test | 37 | ||||
-rw-r--r-- | modules/field/tests/field.test | 4 | ||||
-rw-r--r-- | modules/simpletest/tests/form.test | 2 |
4 files changed, 43 insertions, 12 deletions
diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index 5862ae920..dd7b602fc 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -639,11 +639,13 @@ function text_field_prepare_translation($entity_type, $entity, $field, $instance // If the translating user is not permitted to use the assigned text format, // we must not expose the source values. $field_name = $field['field_name']; - $formats = filter_formats(); - foreach ($source_entity->{$field_name}[$source_langcode] as $delta => $item) { - $format_id = $item['format']; - if (!filter_access($formats[$format_id])) { - unset($items[$delta]); + if (!empty($source_entity->{$field_name}[$source_langcode])) { + $formats = filter_formats(); + foreach ($source_entity->{$field_name}[$source_langcode] as $delta => $item) { + $format_id = $item['format']; + if (!empty($format_id) && !filter_access($formats[$format_id])) { + unset($items[$delta]); + } } } } diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index 51e2ce44a..67aad26b0 100644 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -402,10 +402,38 @@ class TextTranslationTestCase extends DrupalWebTestCase { } /** + * Test that a plaintext textfield widget is correctly populated. + */ + function testTextField() { + // Disable text processing for body. + $edit = array('instance[settings][text_processing]' => 0); + $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); + + // Login as translator. + $this->drupalLogin($this->translator); + + // Create content. + $langcode = LANGUAGE_NONE; + $body = $this->randomName(); + $edit = array( + "title" => $this->randomName(), + "language" => 'en', + "body[$langcode][0][value]" => $body, + ); + + // Translate the article in french. + $this->drupalPost('node/add/article', $edit, t('Save')); + $node = $this->drupalGetNodeByTitle($edit['title']); + $this->drupalGet("node/$node->nid/translate"); + $this->clickLink(t('add translation')); + $this->assertFieldByXPath("//textarea[@name='body[fr][0][value]']", $body, t('The textfield widget is populated.')); + } + + /** * Check that user that does not have access the field format cannot see the * source value when creating a translation. */ - function testMultipleTextField() { + function testTextFieldFormatted() { // Make node body multiple. $edit = array('field[cardinality]' => -1); $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); @@ -419,8 +447,9 @@ class TextTranslationTestCase extends DrupalWebTestCase { // Create an article with the first body input format set to "Full HTML". $langcode = 'en'; + $title = $this->randomName(); $edit = array( - "title" => $this->randomName(), + 'title' => $title, 'language' => $langcode, ); $this->drupalPost('node/add/article', $edit, t('Save')); @@ -438,11 +467,11 @@ class TextTranslationTestCase extends DrupalWebTestCase { } // Login as translator. - $this->drupalLogout(); $this->drupalLogin($this->translator); // Translate the article in french. - $this->drupalGet('node/1/translate'); + $node = $this->drupalGetNodeByTitle($title); + $this->drupalGet("node/$node->nid/translate"); $this->clickLink(t('add translation')); $this->assertNoText($body[0], t('The body field with delta @delta is hidden.', array('@delta' => 0))); $this->assertText($body[1], t('The body field with delta @delta is shown.', array('@delta' => 1))); diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 479b0a966..b932479c8 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -1300,7 +1300,7 @@ class FieldFormTestCase extends FieldTestCase { // Submit with missing required value. $edit = array(); $this->drupalPost('test-entity/add/test-bundle', $edit, t('Save')); - $this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); + $this->assertText(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); // Create an entity $value = mt_rand(1, 127); @@ -1316,7 +1316,7 @@ class FieldFormTestCase extends FieldTestCase { $value = ''; $edit = array("{$this->field_name}[$langcode][0][value]" => $value); $this->drupalPost('test-entity/' . $id . '/edit', $edit, t('Save')); - $this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); + $this->assertText(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); } // function testFieldFormMultiple() { diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index 525a8a291..32865c01e 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -63,7 +63,7 @@ class FormsTestCase extends DrupalWebTestCase { $elements['file']['empty_values'] = $empty_strings; // Regular expression to find the expected marker on required elements. - $required_marker_preg = '@<label.*<span class="form-required" title="This field is required\.">\*</span></label>@'; + $required_marker_preg = '@<label.*<span class="form-required" title="This field is required\.">\*</span>.*</label>@'; // Go through all the elements and all the empty values for them. foreach ($elements as $type => $data) { |