Commit 9ed61459 authored by Dries's avatar Dries

- Patch #394116 by Berdir, jcfiala: converted forum module to new database abstraction layer.

parent 7fb7b346
......@@ -13,7 +13,10 @@ function forum_install() {
// Create tables.
drupal_install_schema('forum');
// Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
db_query("UPDATE {system} SET weight = 1 WHERE name = 'forum'");
db_update('system')
->fields(array('weight' => 1))
->condition('name', 'forum')
->execute();
}
function forum_enable() {
......@@ -55,7 +58,7 @@ function forum_uninstall() {
$vid = variable_get('forum_nav_vocabulary', 0);
taxonomy_vocabulary_delete($vid);
db_query('DROP TABLE {forum}');
drupal_uninstall_schema('forum');
variable_del('forum_containers');
variable_del('forum_nav_vocabulary');
variable_del('forum_hot_topic');
......
This diff is collapsed.
......@@ -89,7 +89,7 @@ class ForumTestCase extends DrupalWebTestCase {
$this->assertText(t('The block settings have been updated.'), t('[New forum topics] Forum block was enabled'));
// Retrieve forum menu id.
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'forum' AND menu_name = 'navigation' AND module = 'system' ORDER BY mlid ASC", 0, 1));
$mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'forum' AND menu_name = 'navigation' AND module = 'system' ORDER BY mlid ASC", 0, 1)->fetchField();
// Add forum to navigation menu.
$edit = array();
......@@ -176,12 +176,12 @@ class ForumTestCase extends DrupalWebTestCase {
$this->assertRaw(t('Created new @type %term.', array('%term' => $name, '@type' => t($type))), t(ucfirst($type) . ' was created'));
// Verify forum.
$term = db_fetch_array(db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = %d AND t.name = '%s' AND t.description = '%s'", variable_get('forum_nav_vocabulary', ''), $name, $description));
$term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description = :desc", array(':vid' => variable_get('forum_nav_vocabulary', ''), ':name' => $name, ':desc' => $description))->fetchAssoc();
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
// Verify forum hierarchy.
$tid = $term['tid'];
$parent_tid = db_result(db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = %d", $tid));
$parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", array(':tid' => $tid))->fetchField();
$this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');
return $term;
......@@ -286,7 +286,7 @@ class ForumTestCase extends DrupalWebTestCase {
$this->drupalGet('admin/help/forum');
$this->assertResponse($response2);
if ($response2 == 200) {
$this->assertTitle(t('Forum | Drupal'), t('Forum help node was displayed'));
$this->assertTitle(t('Forum | Drupal'), t('Forum help title was displayed'));
$this->assertText(t('Forum'), t('Forum help node was displayed'));
$this->assertText(t('Home ' . $crumb . ' Administer ' . $crumb . ' Help'), t('Breadcrumbs were displayed'));
}
......@@ -330,7 +330,10 @@ class ForumTestCase extends DrupalWebTestCase {
$this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title'])), t('Forum node was edited'));
// Verify topic was moved to a different forum.
$forum_tid = db_result(db_query("SELECT tid FROM {forum} WHERE nid = %d AND vid = %d", $node->nid, $node->vid));
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
':nid' => $node->nid,
':vid' => $node->vid,
))->fetchField();
$this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum');
// Delete forum node.
......@@ -351,7 +354,7 @@ class ForumTestCase extends DrupalWebTestCase {
// View forum page.
$this->drupalGet('forum/' . $forum['tid']);
$this->assertResponse(200);
$this->assertTitle($forum['name'] . ' | Drupal', t('Forum node was displayed'));
$this->assertTitle($forum['name'] . ' | Drupal', t('Forum name was displayed'));
if (isset($parent)) {
$this->assertText(t('Home ' . $crumb . ' Forums ' . $crumb . ' @name', array('@name' => $parent['name'])), t('Breadcrumbs were displayed'));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment