upgrade.forum.test 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Upgrade test for forum.module.
  4. */
  5. class ForumUpgradePathTestCase extends UpgradePathTestCase {
  6. public static function getInfo() {
  7. return array(
  8. 'name' => 'Forum upgrade path',
  9. 'description' => 'Upgrade path tests for the Forum module.',
  10. 'group' => 'Upgrade path',
  11. );
  12. }
  13. public function setUp() {
  14. // Path to the database dump files.
  15. $this->databaseDumpFiles = array(
  16. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
  17. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.forum.database.php',
  18. );
  19. parent::setUp();
  20. $this->uninstallModulesExcept(array('comment', 'forum', 'taxonomy'));
  21. }
  22. /**
  23. * Test a successful upgrade (no negotiation).
  24. */
  25. public function testForumUpgrade() {
  26. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  27. // Work around http://drupal.org/node/931512
  28. $this->drupalPost('admin/structure/types/manage/forum/fields', array(), t('Save'));
  29. // The D6 database forum vocabulary contains the term "Fruits" with id 81.
  30. $tid = 81;
  31. $this->drupalGet("forum/$tid");
  32. // There is one forum topic in Fruits, with the title "Apples".
  33. $this->clickLink('Apples');
  34. $this->clickLink('Edit');
  35. // Add a forum topic "Bananas" to the "Fruits" forum.
  36. $edit = array(
  37. 'title' => $title = 'Bananas',
  38. 'body[' . LANGUAGE_NONE . '][0][value]' => $body = 'It is another fruit.',
  39. );
  40. $this->drupalPost("node/add/forum/$tid", $edit, t('Save'));
  41. $type = t('Forum topic');
  42. $this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created');
  43. // Retrieve node object, ensure that the topic was created and in the proper forum.
  44. $node = $this->drupalGetNodeByTitle($title);
  45. $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
  46. $this->assertEqual($node->taxonomy_forums[LANGUAGE_NONE][0]['tid'], $tid, 'Saved forum topic was in the expected forum');
  47. $this->drupalGet("forum/$tid");
  48. $this->assertText('Bananas');
  49. $this->drupalLogout();
  50. $this->drupalGet("node/add/forum/$tid");
  51. $this->assertResponse(200, 'User can access forum creation page.');
  52. }
  53. }