diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info index f51804c..6b5f34d 100644 --- a/modules/simpletest/simpletest.info +++ b/modules/simpletest/simpletest.info @@ -45,5 +45,6 @@ files[] = tests/upgrade/upgrade.locale.test files[] = tests/upgrade/upgrade.menu.test files[] = tests/upgrade/upgrade.node.test files[] = tests/upgrade/upgrade.taxonomy.test +files[] = tests/upgrade/upgrade.translatable.test files[] = tests/upgrade/upgrade.upload.test files[] = tests/upgrade/upgrade.user.test diff --git a/modules/simpletest/tests/upgrade/drupal-6.translatable.database.php b/modules/simpletest/tests/upgrade/drupal-6.translatable.database.php new file mode 100644 index 0000000..5162116 --- /dev/null +++ b/modules/simpletest/tests/upgrade/drupal-6.translatable.database.php @@ -0,0 +1,125 @@ +fields(array( + 'nid', + 'vid', + 'type', + 'language', + 'title', + 'uid', + 'status', + 'created', + 'changed', + 'comment', + 'promote', + 'moderate', + 'sticky', + 'tnid', + 'translate', +)) +->values(array( + 'nid' => '53', + 'vid' => '63', + 'type' => 'translatable_page', + 'language' => 'fr', + 'title' => 'First translatable page', + 'uid' => '1', + 'status' => '1', + 'created' => '1298363952', + 'changed' => '1298363952', + 'comment' => '2', + 'promote' => '0', + 'moderate' => '0', + 'sticky' => '0', + 'tnid' => '0', + 'translate' => '0', +)) +->execute(); + +db_insert('node_revisions')->fields(array( + 'nid', + 'vid', + 'uid', + 'title', + 'body', + 'teaser', + 'log', + 'timestamp', + 'format', +)) +->values(array( + 'nid' => '53', + 'vid' => '63', + 'uid' => '1', + 'title' => 'First translatable page', + 'body' => 'Body of the first translatable page.', + 'teaser' => 'Teaser of the first translatable page.', + 'log' => '', + 'timestamp' => '1298363952', + 'format' => '1', +)) +->execute(); + +db_insert('node_comment_statistics')->fields(array( + 'nid', + 'last_comment_timestamp', + 'last_comment_name', + 'last_comment_uid', + 'comment_count', +)) +->values(array( + 'nid' => '53', + 'last_comment_timestamp' => '1298363952', + 'last_comment_name' => NULL, + 'last_comment_uid' => '1', + 'comment_count' => '0', +)) +->execute(); + +db_insert('node_type')->fields(array( + 'type', + 'name', + 'module', + 'description', + 'help', + 'has_title', + 'title_label', + 'has_body', + 'body_label', + 'min_word_count', + 'custom', + 'modified', + 'locked', + 'orig_type', +)) +->values(array( + 'type' => 'translatable_page', + 'name' => 'Translatable page', + 'module' => 'node', + 'description' => 'A translatable page is like a normal page, but with multilanguage support.', + 'help' => '', + 'has_title' => '1', + 'title_label' => 'Title', + 'has_body' => '1', + 'body_label' => 'Body', + 'min_word_count' => '0', + 'custom' => '0', + 'modified' => '0', + 'locked' => '1', + 'orig_type' => '', +)) +->execute(); + +db_insert('variable')->fields(array( + 'name', + 'value', +)) +->values(array( + 'name' => 'language_content_type_translatable_page', + 'value' => 's:1:"1";', +)) +->execute(); diff --git a/modules/simpletest/tests/upgrade/upgrade.test b/modules/simpletest/tests/upgrade/upgrade.test index 8a3da81..6aadee3 100644 --- a/modules/simpletest/tests/upgrade/upgrade.test +++ b/modules/simpletest/tests/upgrade/upgrade.test @@ -402,5 +402,9 @@ class BasicUpgradePath extends UpgradePathTestCase { // Confirm that no {menu_links} entry exists for user/autocomplete. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField(); $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete')); + + // Test that the environment after the upgrade is in a consistent status. + $update_d6 = variable_get('update_d6', FALSE); + $this->assertFalse($update_d6, t('The D6 upgrade flag variable has been correctly disabled.')); } } diff --git a/modules/simpletest/tests/upgrade/upgrade.translatable.test b/modules/simpletest/tests/upgrade/upgrade.translatable.test new file mode 100644 index 0000000..c9360f3 --- /dev/null +++ b/modules/simpletest/tests/upgrade/upgrade.translatable.test @@ -0,0 +1,51 @@ + 'Translatable content upgrade path', + 'description' => 'Upgrade path tests for the translatable content types of Node module.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + // Path to the database dump files. + $this->databaseDumpFiles = array( + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php', + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.locale.database.php', + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.translatable.database.php', + ); + parent::setUp(); + + $this->uninstallModulesExcept(array('locale')); + } + + /** + * Test a successful upgrade (no negotiation). + */ + public function testTranslatableUpgrade() { + $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); + + // The D6 database contains the english node "First translatable page" with + // nid 53. + $nid = 53; + $title = 'First translatable page'; + $teaser = 'Teaser of the first translatable page.'; + $body = 'Body of the first translatable page.'; + + // Check whether the node displays properly. + $this->drupalGet("node/$nid"); + $this->assertText($body, t('Translatable node body displays properly')); + + // Retrieve node object, ensure that both the body and the teaser has + // survived upgrade properly. + $node = $this->drupalGetNodeByTitle($title); + $this->assertTrue($node != NULL, t('Node @title was loaded', array('@title' => $title))); + $this->assertEqual($node->body[LANGUAGE_NONE][0]['value'], $body, 'Body of the node survived upgrade properly'); + $this->assertEqual($node->body[LANGUAGE_NONE][0]['summary'], $teaser, 'Teaser of the node survived upgrade properly'); + } +}