diff --git a/forum.module b/forum.module index 06ec84c..3fd3bc6 100644 --- a/forum.module +++ b/forum.module @@ -550,7 +550,7 @@ function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) { */ function forum_form_taxonomy_form_vocabulary_alter(&$form, &$form_state, $form_id) { $vid = config_get('forum.settings', 'forum_nav_vocabulary'); - if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) { + if (isset($form['machine_name']['#default_value']) && $form['machine_name']['#default_value'] == $vid) { $form['help_forum_vocab'] = array( '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'), '#weight' => -1, @@ -569,7 +569,7 @@ function forum_form_taxonomy_form_vocabulary_alter(&$form, &$form_state, $form_i */ function forum_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id) { $vid = config_get('forum.settings', 'forum_nav_vocabulary'); - if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) { + if (isset($form['vocabulary']['#value']) && $form['vocabulary']['#value'] == $vid) { // Hide multiple parents select from forum terms. $form['relations']['parent']['#access'] = FALSE; } @@ -936,6 +936,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $topics = array(); $first_new_found = FALSE; foreach ($result as $topic) { + $topic = entity_create('node', (array) $topic); if ($user->uid) { // A forum is new if the topic is new, or if there are new comments since // the user's last visit. diff --git a/tests/forum.test b/tests/forum.test index b92b745..ebe71cc 100644 --- a/tests/forum.test +++ b/tests/forum.test @@ -175,12 +175,12 @@ class ForumTestCase extends BackdropWebTestCase { $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.'); // Verify total number of posts in forum. - $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="posts"]', $forum_arg); + $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="posts priority-low"]', $forum_arg); $this->assertFieldByXPath($xpath, '6', 'Number of posts found.'); // Test loading multiple forum nodes on the front page. $this->backdropLogin($this->backdropCreateUser(array('administer content types', 'create forum content'))); - $this->backdropPost('admin/structure/types/manage/forum', array('node_options[promote]' => 'promote'), t('Save content type')); + $this->backdropPost('admin/structure/types/manage/forum', array('promote_default' => 1), t('Save content type')); $this->createForumTopic($this->forum, FALSE); $this->createForumTopic($this->forum, FALSE); $this->backdropGet('node'); @@ -232,7 +232,7 @@ class ForumTestCase extends BackdropWebTestCase { $this->backdropPost('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.'); + $this->assertEqual(2, $nid_count, 'A forum node was not created when missing a forum vocabulary.'); // Reset the defaults for future tests. module_enable(array('forum')); @@ -250,13 +250,13 @@ class ForumTestCase extends BackdropWebTestCase { // Enable the active forum block. $layout = layout_load('default'); - $layout->addBlock('forum', 'forum_active', 'footer'); + $layout->addBlock('forum', 'active', 'footer'); $layout->save(); - $forum_active_selector = "//*[contains(@class,'block-forum-new')]"; - $this->backdropGet('node'); + $forum_active_selector = "//*[contains(@class,'block-forum-active')]"; + $this->backdropGet('node/1'); $elements = $this->xpath($forum_active_selector); - $this->assertEqual(count($elements), 1, 'Active forum block found on /node.'); + $this->assertEqual(count($elements), 1, 'Active forum block found on /node/1.'); $this->backdropGet('user'); $elements = $this->xpath($forum_active_selector); @@ -264,13 +264,13 @@ class ForumTestCase extends BackdropWebTestCase { // Enable the new forum block. $layout = layout_load('default'); - $layout->addBlock('forum', 'forum_new', 'footer'); + $layout->addBlock('forum', 'new', 'footer'); $layout->save(); $forum_new_selector = "//*[contains(@class,'block-forum-new')]"; - $this->backdropGet('node'); + $this->backdropGet('node/1'); $elements = $this->xpath($forum_new_selector); - $this->assertEqual(count($elements), 1, 'New forum block found on /node.'); + $this->assertEqual(count($elements), 1, 'New forum block found on /node/1.'); $this->backdropGet('user'); $elements = $this->xpath($forum_new_selector); @@ -312,7 +312,7 @@ class ForumTestCase extends BackdropWebTestCase { $this->root_forum = $this->createForum('forum'); // Test vocabulary form alterations. - $this->backdropGet('admin/structure/taxonomy/forums/edit'); + $this->backdropGet('admin/structure/taxonomy/forums/configure'); $this->assertFieldByName('op', t('Save'), 'Save button found.'); $this->assertNoFieldByName('op', t('Delete'), 'Delete button not found.'); @@ -322,9 +322,8 @@ class ForumTestCase extends BackdropWebTestCase { $this->assertNoField('parent[]', 'Parent field not found.'); // Test tags vocabulary form is not affected. - $this->backdropGet('admin/structure/taxonomy/tags/edit'); + $this->backdropGet('admin/structure/taxonomy/tags/configure'); $this->assertFieldByName('op', t('Save'), 'Save button found.'); - $this->assertFieldByName('op', t('Delete'), 'Delete button found.'); // Test tags vocabulary term form is not affected. $this->backdropGet('admin/structure/taxonomy/tags/add'); $this->assertField('parent[]', 'Parent field found.'); @@ -351,7 +350,7 @@ class ForumTestCase extends BackdropWebTestCase { ); // Edit the vocabulary. - $this->backdropPost('admin/structure/taxonomy/' . $original_settings->machine_name . '/edit', $edit, t('Save')); + $this->backdropPost('admin/structure/taxonomy/' . $original_settings->machine_name . '/configure', $edit, t('Save')); $this->assertResponse(200); $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), 'Vocabulary was edited'); @@ -420,8 +419,7 @@ class ForumTestCase extends BackdropWebTestCase { */ function deleteForum($tid) { // Delete the forum. - $this->backdropPost('admin/structure/forum/edit/forum/' . $tid, array(), t('Delete')); - $this->backdropPost(NULL, array(), t('Delete')); + $this->backdropPost('taxonomy/term/' . $tid . '/delete', array(), t('Delete')); // Assert that the forum no longer exists. $this->backdropGet('forum/' . $tid); @@ -480,12 +478,11 @@ class ForumTestCase extends BackdropWebTestCase { $type = t('Forum topic'); if ($container) { - $this->assertNoRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was not created'); $this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'Error message was shown'); return; } else { - $this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created'); + $this->assertRaw($title, 'Forum topic was created'); $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown'); } @@ -515,18 +512,9 @@ class ForumTestCase extends BackdropWebTestCase { * The exptected HTTP response code. */ private function verifyForums($node_user, $node, $admin, $response = 200) { - $response2 = ($admin) ? 200 : 403; - - // View forum help node. - $this->backdropGet('admin/help/forum'); - $this->assertResponse($response2); - if ($response2 == 200) { - $this->assertTitle(t('Forum | Backdrop'), 'Forum help title was displayed'); - $this->assertText(t('Forum'), 'Forum help node was displayed'); - } // Verify the forum blocks were displayed. - $this->backdropGet(''); + $this->backdropGet('node/' . $node->nid); $this->assertResponse(200); $this->assertText(t('New forum topics'), '[New forum topics] Forum block was displayed'); @@ -540,20 +528,22 @@ class ForumTestCase extends BackdropWebTestCase { // View forum node. $this->backdropGet('node/' . $node->nid); $this->assertResponse(200); - $this->assertTitle($node->title . ' | Backdrop', 'Forum node was displayed'); + $this->assertTitle($node->title . ' | ' . config_get('system.core', 'site_name'), 'Forum node was displayed'); $breadcrumb = array( - l(t('Home'), NULL), - l(t('Forums'), 'forum'), - l($this->container['name'], 'forum/' . $this->container['tid']), - l($this->forum['name'], 'forum/' . $this->forum['tid']), + t('Home'), + t('Forums'), + $this->container['name'], + $this->forum['name'], ); - $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed'); + foreach ($breadcrumb as $bc) { + $this->assertLink($bc, 0, 'Breadcrumb was displayed: ' . $bc); + } // View forum edit node. $this->backdropGet('node/' . $node->nid . '/edit'); $this->assertResponse($response); if ($response == 200) { - $this->assertTitle('Edit Forum topic ' . $node->title . ' | Backdrop', 'Forum edit node was displayed'); + $this->assertTitle('Edit Forum topic ' . $node->title . ' | ' . config_get('system.core', 'site_name'), 'Forum edit node was displayed'); } if ($response == 200) { @@ -594,17 +584,18 @@ class ForumTestCase extends BackdropWebTestCase { // View forum page. $this->backdropGet('forum/' . $forum['tid']); $this->assertResponse(200); - $this->assertTitle($forum['name'] . ' | Backdrop', 'Forum name was displayed'); + $this->assertTitle($forum['name'] . ' | ' . config_get('system.core', 'site_name'), 'Forum name was displayed'); $breadcrumb = array( - l(t('Home'), NULL), - l(t('Forums'), 'forum'), + t('Home'), + t('Forums'), ); if (isset($parent)) { - $breadcrumb[] = l($parent['name'], 'forum/' . $parent['tid']); + $breadcrumb[] = $parent['name']; + } + foreach ($breadcrumb as $bc) { + $this->assertLink($bc, 0, 'Breadcrumb was displayed: ' . $bc); } - - $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed'); } /** @@ -693,7 +684,7 @@ class ForumIndexTestCase extends BackdropWebTestCase { // Unpublish the node. $edit = array( - 'status' => FALSE, + 'status' => 0, ); $this->backdropPost("node/{$node->nid}/edit", $edit, t('Save')); $this->backdropGet("node/{$node->nid}");