From #299176: Replace db_rewrite_sql() with hook_query_alter(). it was found that we need some tests for the forum module blocks. Anyone want to take a stab at this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Priority: Critical » Normal

Moving this out of the critical bugs queue - see #607038: Meta issue: fix gaps in code coverage.

Shawn DeArmond’s picture

Taking a stab... patch forthcoming...

Shawn DeArmond’s picture

Status: Active » Needs review
FileSize
7.75 KB

Here's my stab.

Status: Needs review » Needs work

The last submitted patch, 440344_forum_block_tests.patch, failed testing.

Shawn DeArmond’s picture

Huh? It passed on my computer. I just tried it again. What's going on?

Shawn DeArmond’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

#3: 440344_forum_block_tests.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests

The last submitted patch, 440344_forum_block_tests.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
7.51 KB

Re-roll, a few doc changes and node_load_multiple($result->fetchCol()) to simplify some DBTNG code.

Status: Needs review » Needs work

The last submitted patch, 440344_forum_block_tests2.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
7.87 KB

Ah, yeah, the usual :)

Test bot doesn't have clean url's enabled and isn't installed in example.org/ (but example.org/something), so you can't do something like assertRaw() on 'href="/node/5"'.

Here's a re-roll which uses xpath. Note that I did not review if the tests are correct, I just re-rolled and fixed the fails.

Shawn DeArmond’s picture

Aha! Thanks! That was driving me crazy. I had pretty much given up.

Artusamak’s picture

Status: Needs work » Needs review
+++ modules/forum/forum.test
@@ -72,7 +79,8 @@ class ForumTestCase extends DrupalWebTestCase {
     // Verify the topic and post counts on the forum page.
     $this->drupalGet('forum');
     $this->assertRaw("<td class=\"topics\">\n          6                  </td>");
-    $this->assertRaw('<td class="posts">6</td>');
+    $this->post_count += 4;
+    $this->assertRaw('<td class="posts">'. $this->post_count .'</td>');
 
     // Test loading multiple forum nodes on the front page.
     $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content')));

This chunk isn't working (patching failed).

+++ modules/forum/forum.test
@@ -367,9 +450,41 @@ class ForumTestCase extends DrupalWebTestCase {
+      $s = $newest_topic['comment_count'] > 1 ? 's' : '';

$s should be renamed as $plural and use core function format_plural().
$plural = format_plural($newest_topic['comment_count'], '', 's');

+++ modules/forum/forum.test
@@ -367,9 +450,41 @@ class ForumTestCase extends DrupalWebTestCase {
+      $s = $newest_topic['comment_count'] > 1 ? 's' : '';
+      $title = $title_xpath = '';
+      if ($newest_topic['comment_count']) {
+        $title = $newest_topic['comment_count'] . ' comment' . $s;
+        $title_xpath = ' and @title=:title';
+      }

The statement for the plural form should be inside the if statement otherwise you could have warning generated.

The rest of the patch is okay.

Powered by Dreditor.

Artusamak’s picture

Status: Needs review » Needs work

Status: Needs review » Needs work