function ForumTestCase::testAddOrphanTopic in Drupal 7
Tests that forum nodes can't be added without a parent.
Verifies that forum nodes are not created without choosing "forum" from the select list.
File
- modules/
forum/ forum.test, line 216 - Tests for forum.module.
Class
- ForumTestCase
- Provides automated tests for the 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, 'A forum node was not created when missing a forum vocabulary.');
// Reset the defaults for future tests.
module_enable(array(
'forum',
));
}