summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 05:57:05 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 05:57:05 +0000
commit8dfd725b3c68c175952f74af6916cef16f2ac115 (patch)
treee012d996f6a271bed044b9c8830416a6b22a72d7 /modules
parent0da45208f450ef39593dfab104daa7ec39049fdc (diff)
downloadbrdo-8dfd725b3c68c175952f74af6916cef16f2ac115.tar.gz
brdo-8dfd725b3c68c175952f74af6916cef16f2ac115.tar.bz2
#608424 by peximo and plach: Fixed notice when multilingual body display set to hidden (with tests).
Diffstat (limited to 'modules')
-rw-r--r--modules/locale/locale.field.inc2
-rw-r--r--modules/locale/locale.test48
2 files changed, 43 insertions, 7 deletions
diff --git a/modules/locale/locale.field.inc b/modules/locale/locale.field.inc
index 0461f5082..b304ce329 100644
--- a/modules/locale/locale.field.inc
+++ b/modules/locale/locale.field.inc
@@ -52,7 +52,7 @@ function locale_field_fallback_view(&$output, $context) {
// If the items array is empty then we have a missing field translation.
// @todo: Verify this assumption.
- if (empty($output[$field_name]['items'])) {
+ if (isset($output[$field_name]) && empty($output[$field_name]['items'])) {
if (!isset($fallback_candidates)) {
require_once DRUPAL_ROOT . '/includes/language.inc';
$fallback_candidates = language_fallback_get_candidates();
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 75e96a0b7..15cdf6d9d 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1634,12 +1634,6 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
function setUp() {
parent::setUp('locale');
- }
-
- /**
- * Test if field languages are correctly set through the node form.
- */
- function testMultilingualNodeForm() {
// Setup users.
$admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'create page content', 'edit own page content'));
$this->drupalLogin($admin_user);
@@ -1656,7 +1650,12 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
);
$this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Page')), t('Page content type has been updated.'));
+ }
+ /**
+ * Test if field languages are correctly set through the node form.
+ */
+ function testMultilingualNodeForm() {
// Create page content.
$langcode = FIELD_LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
@@ -1691,6 +1690,43 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
$assert = isset($node->body['it']) && !isset($node->body['en']) && $node->body['it'][0]['value'] == $body_value;
$this->assertTrue($assert, t('Field language correctly changed.'));
}
+
+ /*
+ * Test multilingual field display settings.
+ */
+ function testMultilingualDisplaySettings() {
+ // Create page content.
+ $langcode = FIELD_LANGUAGE_NONE;
+ $title_key = "title[$langcode][0][value]";
+ $title_value = $this->randomName(8);
+ $body_key = "body[$langcode][0][value]";
+ $body_value = $this->randomName(16);
+
+ // Create node to edit.
+ $edit = array();
+ $edit[$title_key] = $title_value;
+ $edit[$body_key] = $body_value;
+ $edit['language'] = 'en';
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+
+ // Check that the node exists in the database.
+ $node = $this->drupalGetNodeByTitle($edit[$title_key]);
+ $this->assertTrue($node, t('Node found in database.'));
+
+ // Check if node body is showed.
+ $this->drupalGet("node/$node->nid");
+ $body_xpath = '//div[@id="node-' . $node->nid . '"]//div[@property="content:encoded"]/p';
+ $this->assertEqual(current($this->xpath($body_xpath)), $node->body['en'][0]['value'], 'Node body is correctly showed.', 'Node');
+
+ $settings['body[full][type]'] = 'hidden';
+ $this->drupalPost('admin/structure/types/manage/page/display', $settings, t('Save'));
+ $select_xpath = '//select[@id="edit-body-full-type"]/option[@selected="selected"]';
+ // Check if body display is actually "hidden" for the "full" build mode.
+ $this->assertEqual(current($this->xpath($select_xpath)), '<Hidden>', 'Body display is actually "hidden" for the "full" build mode');
+ $this->drupalGet("node/$node->nid");
+ // Check if node body is not showed.
+ $this->assertFalse(is_array($this->xpath($body_xpath)), 'Body correctly not showed.');
+ }
}
/**