summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.forum.test
blob: b0bbd4ed788f381689e3ddee1226587e0680e253 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

/**
 * Upgrade test for forum.module.
 */
class ForumUpgradePathTestCase extends UpgradePathTestCase {
  public static function getInfo() {
    return array(
      'name'  => 'Forum upgrade path',
      'description'  => 'Upgrade path tests for the Forum 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.forum.database.php',
    );
    parent::setUp();

    $this->uninstallModulesExcept(array('comment', 'forum', 'taxonomy'));
  }

  /**
   * Test a successful upgrade (no negotiation).
   */
  public function testForumUpgrade() {
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');

    // Work around http://drupal.org/node/931512
    $this->drupalPost('admin/structure/types/manage/forum/fields', array(), t('Save'));

    // The D6 database forum vocabulary contains the term "Fruits" with id 81.
    $tid = 81;
    $this->drupalGet("forum/$tid");

    // There is one forum topic in Fruits, with the title "Apples".
    $this->clickLink('Apples');
    $this->clickLink('Edit');

    // Add a forum topic "Bananas" to the "Fruits" forum.
    $edit = array(
      'title' => $title = 'Bananas',
      'body[' . LANGUAGE_NONE . '][0][value]' => $body = 'It is another fruit.',
    );
    $this->drupalPost("node/add/forum/$tid", $edit, t('Save'));
    $type = t('Forum topic');
    $this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created');

    // Retrieve node object, ensure that the topic was created and in the proper forum.
    $node = $this->drupalGetNodeByTitle($title);
    $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
    $this->assertEqual($node->taxonomy_forums[LANGUAGE_NONE][0]['tid'], $tid, 'Saved forum topic was in the expected forum');

    $this->drupalGet("forum/$tid");
    $this->assertText('Bananas');
    $this->drupalLogout();

    $this->drupalGet("node/add/forum/$tid");
    $this->assertResponse(200, 'User can access forum creation page.');
  }
}