ForumTestCase::testAddOrphanTopic

7 forum.test ForumTestCase::testAddOrphanTopic()
8 forum.test ForumTestCase::testAddOrphanTopic()

Forum nodes should not be created without choosing forum from select list.

File

modules/forum/forum.test, line 173
Tests for forum.module.

Code

function testAddOrphanTopic() {
  // Must remove forum topics to test creating orphan topics.
  $vid = variable_get('forum_nav_vocabulary');
  $tree = taxonomy_get_tree($vid);
  foreach ($tree as $term) {
    taxonomy_term_delete($term->tid);
  }

  // Create an orphan forum item.
  $this->drupalLogin($this->admin_user);
  $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(120)), t('Save'));

  $nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
  $this->assertEqual(0, $nid_count, t('A forum node was not created when missing a forum vocabulary.'));

  // Reset the defaults for future tests.
  module_enable(array('forum'));
}
Login or register to post comments