This issue fails for several reasons:

  • Core contains bugs, not covered by tests. (Someone managed to change check_markup()'s function signature, but not all instances throughout core.)
  • This test does not fit into any module's .test file, but in parallel, it fits into all related module's .test files.
  • I can only select one component for this issue, while the bug, as well as the test, affects several modules.
  • This is where unit tests end, and inter-dependent functionality needs to be tested. Comment relies on Node, Search relies on Comment, Comment relies on Filter module. FWIW, check_markup() is invoked wrongly, and check_markup() belongs to filter.module, which is why this issue is assigned to component 'filter.module' (well, also to have it in my watchlist).

Last, but not least, this patch should fail and return 2 errors. When that happens, I'll add the two bits that should make it pass.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Component: comment.module » filter.module

uhm.

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

Another FAIL:

- Someone updated hook_nodeapi() to be split into individual functions and managed to invoke module_invoke() in a completely weird way:

        // Fetch comments for snippet.
        $node->body .= module_invoke('comment', 'node', $node, 'update_index');
        // Fetch terms for snippet.
        $node->body .= module_invoke('taxonomy', 'node', $node, 'update_index');
sun’s picture

Assigned: sun » Unassigned
Status: Needs work » Needs review
FileSize
6.95 KB

Seriously, I thought I would fix 1 tiny bug here... I need a break.

1)

+      // @todo Comments are added to search index without checking first whether
+      //   anonymous users are allowed to access comments.

2)

+      // @todo Without this permission, "Login or register to post comments" is
+      //   added to the search index.  Scratch that, comment.module did not even
+      //   add anything to search results.  Aforementioned link text must be
+      //   added via node links.
+      '1[post comments]' => 1,

3) Someone should ensure that all instances of ex. hook_nodeapi() were correctly converted into hook_node_X(), resp. module_invoke('foo', 'node_X', ...)

         // Fetch comments for snippet.
-        $node->body .= module_invoke('comment', 'node', $node, 'update_index');
+        $node->body .= module_invoke('comment', 'node_update_index', $node);
         // Fetch terms for snippet.
-        $node->body .= module_invoke('taxonomy', 'node', $node, 'update_index');
+        $node->body .= module_invoke('taxonomy', 'node_update_index', $node);

Anyway. This patch is RTBC.

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
6.95 KB

huh? Passes for me. Re-test.

sun’s picture

Now invoking cron the same way like system.test. Thanks for the pointer, chx.

Dave Reid’s picture

Yeah using url() with cron.php/update.php doesn't work since the test bot runs in a subdirectory apparently. I had the same problem with tests and drupalGet() with adding a permission to run update.php.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Wow, lots of bugfixes. And, nice ASCII art.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review
+    $edit = array(
+      '1[search content]' => 1,
+      // @todo Comments are added to search index without checking first whether
+      //   anonymous users are allowed to access comments.
+      '1[access comments]' => 1,
+      // @todo Without this permission, "Login or register to post comments" is
+      //   added to the search index.  Scratch that, comment.module did not even
+      //   add anything to search results.  Aforementioned link text must be
+      //   added via node links.
+      '1[post comments]' => 1,
+    );

Should be using
DRUPAL_ANONYMOUS_RID . '[search content]' => 1, etc
Side node, I should really get back on #300993: User roles and permissions API so we don't have to use code like this in tests...

+    // Create a node.
+    $edit = array(
+      'title' => $this->randomName(),
+    );
+    $this->drupalPost('node/add/page', $edit, t('Save'));
+    // Check that the node exists in the database.

Why not use drupalCreateNode() since you're not doing anything special?

And yes, the ASCII art is funny/cool...but seriously...

sun’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
7.02 KB

Of course, the contained code to setup the check_plain() filter had a purpose. search_excerpt() strips all tags from the snippet that is displayed in the search results. If the content was formatted with the wrong text format, the HTML would be escaped.

Added this last assertion and clarified @todo 2) about the node comment link that's added to search index.

sun’s picture

Incorporated all points from Dave Reid's review in #10.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Since there were no steps posted to reproduce the bugs identified here (grumble, mutter), I had to reverse-engineer the test to figure it out. I came across some things when I did.

+    // Enable comments for 'page' nodes.
+    variable_set('comment_page', COMMENT_NODE_OPEN);
+    variable_set('comment_preview_page', COMMENT_PREVIEW_OPTIONAL);

There's already enough going on in this test; let's not muddy the waters more by adding comments to Pages as well; just use article. If we don't have coverage for comments on Pages, let's put it in comment.test in a separate issue, since it seems unrelated to these bugs here.

--- modules/filter/filter.test	25 Apr 2009 18:01:10 -0000	1.19
+++ modules/filter/filter.test	28 Apr 2009 02:27:59 -0000

Speaking of test locations, I realize that the bugs ultimately lie in the filter system, but the test is clearly an integration test of the search functionality, and should be relocated to search.test IMO. I can't forsee anyone ever finding this test in filter.test once all of the underlying bugs are fixed.

+    // Enable check_plain() for 'Filtered HTML' text format.
+    $edit = array(
+      'filters[filter/0]' => 1,
+      'filters[filter/1]' => 1,
+      'filters[filter/2]' => 1,
+      'filters[filter/3]' => 1,
+      'filters[filter/4]' => 1,
+    );

Why do we need to specify 1 for each of them, if we're only interested in "Escape all HTML"? Again, let's please keep the test focused only to what it needs to do to exhibit the buggy behaviour. Unless this is required, in which case, please clarify in the comment. Also, please add the "Escape all HTML" keywords to the comment as well.

+    /**
+     *                     ,____
+     *                     |---.\
+     *             ___     |    `
+     *            / .-\  ./=)
+     *           |  |"|_/\/|
+     *           ;  |-;| /_|
+     *          / \_| |/ \ |
+     *         /      \/\( |
+     *         |   /  |` ) |
+     *         /   \ _/    |
+     *        /--._/  \    |
+     *        `/|)    |    /
+     *          /     |   |
+     *        .'      |   |
+     * jgs   /         \  |
+     *      (_.-.__.__./  /
+     * @see http://drupal.org/cvs?commit=79939
+     */

:P

+    $this->assertText($title, t('Comment body text found in search results.'));

Forgive my ignorance, but how does this prove anything? Unless I'm really tired, you're using the same text for both the title of the node and the body of the comment, so this test will pass even without this patch.

dmitrig01’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.19 KB

Fixed on all counts

dmitrig01’s picture

this time for real

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Committed to CVS. Thanks for the patch, and the reviews.

sun’s picture

Status: Fixed » Needs work

Hrm. Bugs, bugs, bugs.

#295864: SimpleTest: Change randomName() method to randomString() changed the function signature of $this->randomName().

sun’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.11 KB
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.