summaryrefslogtreecommitdiff
path: root/modules/translation
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-09 03:22:30 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-09 03:22:30 +0000
commit7d0e6716940f0c46f9bc0ebe8bf14f331ca1b821 (patch)
treece8d27ec636390ea9d3b79b220af7827863e09b3 /modules/translation
parentb737a40c76d85e8836de548a923d371492bfafa5 (diff)
downloadbrdo-7d0e6716940f0c46f9bc0ebe8bf14f331ca1b821.tar.gz
brdo-7d0e6716940f0c46f9bc0ebe8bf14f331ca1b821.tar.bz2
#357785 by miro_dietiker, plach: Fixed tnid value lost in case of node resave.
Diffstat (limited to 'modules/translation')
-rw-r--r--modules/translation/tests/translation_test.info8
-rw-r--r--modules/translation/tests/translation_test.module14
-rw-r--r--modules/translation/translation.module2
-rw-r--r--modules/translation/translation.test11
4 files changed, 30 insertions, 5 deletions
diff --git a/modules/translation/tests/translation_test.info b/modules/translation/tests/translation_test.info
new file mode 100644
index 000000000..c4c1a8e94
--- /dev/null
+++ b/modules/translation/tests/translation_test.info
@@ -0,0 +1,8 @@
+; $Id$
+name = "Content Translation Test"
+description = "Support module for the content translation tests."
+core = 7.x
+package = Testing
+files[] = translation_test.module
+version = VERSION
+hidden = TRUE
diff --git a/modules/translation/tests/translation_test.module b/modules/translation/tests/translation_test.module
new file mode 100644
index 000000000..2bb860d6f
--- /dev/null
+++ b/modules/translation/tests/translation_test.module
@@ -0,0 +1,14 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Mock module for content translation tests.
+ */
+
+/**
+ * Implements hook_node_insert().
+ */
+function translation_test_node_insert($node) {
+ drupal_write_record('node', $node, 'nid');
+}
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index c6edf6744..03bf079c9 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -272,6 +272,8 @@ function translation_node_insert($node) {
))
->condition('nid', $node->nid)
->execute();
+ // Save tnid to avoid loss in case of resave.
+ $node->tnid = $tnid;
}
}
}
diff --git a/modules/translation/translation.test b/modules/translation/translation.test
index d72fd390a..1930b591f 100644
--- a/modules/translation/translation.test
+++ b/modules/translation/translation.test
@@ -13,7 +13,7 @@ class TranslationTestCase extends DrupalWebTestCase {
}
function setUp() {
- parent::setUp('locale', 'translation');
+ parent::setUp('locale', 'translation', 'translation_test');
}
/**
@@ -148,7 +148,7 @@ class TranslationTestCase extends DrupalWebTestCase {
/**
* Create a translation for the specified basic page in the specified language.
*
- * @param integer $nid Node id of basic page to create translation for.
+ * @param object $node The basic page to create translation for.
* @param string $title Title of basic page in specified language.
* @param string $body Body of basic page in specified language.
* @param string $language Language code.
@@ -167,9 +167,10 @@ class TranslationTestCase extends DrupalWebTestCase {
$this->assertRaw(t('Basic page %title has been created.', array('%title' => $title)), t('Translation created.'));
// Check to make sure that translation was successful.
- $node = $this->drupalGetNodeByTitle($title);
- $this->assertTrue($node, t('Node found in database.'));
+ $translation = $this->drupalGetNodeByTitle($title);
+ $this->assertTrue($translation, t('Node found in database.'));
+ $this->assertTrue($translation->tnid == $node->nid, t('Translation set id correctly stored.'));
- return $node;
+ return $translation;
}
}