- Patch #613272 by Kevin Hankens, Dave Reid, yoroy, rgristroph, pcarman: forums not usable out-of-the-box: disabled comments, no forums.
parent
96bfc650bc
commit
9f70b717e5
|
@ -20,6 +20,9 @@ function forum_install() {
|
|||
variable_set('node_options_forum', array('status'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_enable().
|
||||
*/
|
||||
function forum_enable() {
|
||||
// Create the forum vocabulary if it does not exist.
|
||||
$vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
|
||||
|
@ -66,6 +69,16 @@ function forum_enable() {
|
|||
field_create_instance($instance);
|
||||
|
||||
variable_set('forum_nav_vocabulary', $vocabulary->vid);
|
||||
|
||||
// Create a default forum so forum posts can be created.
|
||||
$edit = array(
|
||||
'name' => t('General discussion'),
|
||||
'description' => '',
|
||||
'parent' => array(0),
|
||||
'vid' => $vocabulary->vid,
|
||||
);
|
||||
$term = (object) $edit;
|
||||
taxonomy_term_save($term);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -307,6 +307,10 @@ function forum_node_validate($node, $form) {
|
|||
continue;
|
||||
}
|
||||
$term = taxonomy_term_load($item['tid']);
|
||||
if (!$term) {
|
||||
form_set_error('taxonomy_forums', t('Select a forum.'));
|
||||
continue;
|
||||
}
|
||||
$used = db_query_range('SELECT 1 FROM {taxonomy_term_data} WHERE tid = :tid AND vid = :vid',0 , 1, array(
|
||||
':tid' => $term->tid,
|
||||
':vid' => $term->vid,
|
||||
|
|
|
@ -35,6 +35,11 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
* Login users, create forum nodes, and test forum functionality through the admin and user interfaces.
|
||||
*/
|
||||
function testForum() {
|
||||
//Check that the basic forum install creates a default forum topic
|
||||
$this->drupalGet("/forum");
|
||||
// Look for the "General discussion" default forum
|
||||
$this->assertText(t("General discussion"), "Found the default forum at the /forum listing");
|
||||
|
||||
// Do the admin tests.
|
||||
$this->doAdminTests($this->admin_user);
|
||||
// Generate topics to populate the active forum block.
|
||||
|
@ -94,11 +99,22 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
* Forum nodes should not be created without choosing forum from select list.
|
||||
*/
|
||||
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.'));
|
||||
$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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue