TestingParty08: viewing an individual comment

catch - August 17, 2008 - 20:40
Project:Drupal
Version:7.x-dev
Component:tests
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

comment_render() iirc. Check it shows up properly, body, subject etc.

#1

lyricnz - August 31, 2008 - 14:12
Status:active» needs review

See attached patch, which uses the reply-to-comment screen to check the output of an individual comment.

AttachmentSizeStatusTest resultOperations
individual-comment.test.patch1.22 KBIgnoredNoneNone

#2

boombatower - September 1, 2008 - 23:07
Status:needs review» needs work

Very simple patch. :)

Comment test results:

473 passes, 0 fails, 0 exceptions

I think instead the test should be placed in postComment() since that already checks for the subject showing up. could just add body and w/e else.

<?php
   
// Get comment.
   
if ($contact !== TRUE) { // If true then attempting to find error message.
     
$this->assertText($subject, 'Comment posted.');
     
$this->assertTrue((!empty($match) && !empty($match[1])), t('Comment id found.'));
    }
?>

Right after $subject.

#3

lyricnz - September 7, 2008 - 14:13

Basically a one-line patch? :) Attached.

AttachmentSizeStatusTest resultOperations
comment-test.checksubject.patch739 bytesIgnoredNoneNone

#4

lyricnz - September 7, 2008 - 14:14
Status:needs work» needs review

Tested locally. "479 passes, 0 fails, 0 exceptions" (comment.test)

#5

chx - September 7, 2008 - 14:20
Status:needs review» needs work

Nope. We want a drupalGet("node/$nid/$cid") and check whether the comment appeared there.

#6

lyricnz - September 7, 2008 - 14:40
Status:needs work» needs review

chx is right, while these tests are good, none of them address the issue described in the subject. The attached patch:
- checks comment subject/text on the node/NID/CID page (single comment view - what this issue was asking for)
- checks comment subject/text on the comment/reply/NID/CID page (comment reply view)
- checks comment text on every post-comment page (subject was already checked)

AttachmentSizeStatusTest resultOperations
individual-comment.test.patch1.83 KBIgnoredNoneNone

#7

lyricnz - September 7, 2008 - 14:43

484 passes, 0 fails, 0 exceptions (comment.test)

#8

chx - September 7, 2008 - 14:44
Status:needs review» reviewed & tested by the community

/me likes.

#9

catch - September 8, 2008 - 03:38

I never ever knew we had node/nid/cid, ever.

#10

Dries - September 8, 2008 - 21:30

I wonder whether we still generate node/nid/cid links ... If not, this might actually be dead code?

#11

catch - September 8, 2008 - 21:32

I don't think there's a link to them anywhere, or if there is, then I'm completely unaware of where that might be. However I checked on a D5 site and those pages do indeed exist. They seem a bit pointless though.

#12

chx - September 9, 2008 - 13:27

Haha we have written a test and it revealed that the code being tested is dead?? Because indeed I grepped node/ in comment directory and can't see where this is being created...

#13

lyricnz - September 10, 2008 - 03:47
Status:reviewed & tested by the community» patch (to be ported)

I did a similar search - for 'node/' and nid and cid, across the entire codebase (since the menu entry that handles this is actually added by node.module), and didn't find anything.

Interestingly, support for this URL seems to be almost a side effect:

<?php
function node_menu() {
 
// ...
 
$items['node/%node'] = array(
   
// ...
   
'page callback' => 'node_page_view',
   
'page arguments' => array(1),
   
// ...
   
'type' => MENU_CALLBACK);
 
// ...
}

function
node_page_view($node, $cid = NULL) {
 
drupal_set_title(check_plain($node->title));
  return
node_show($node, $cid);
}

function
node_show($node, $cid, $message = FALSE) {
 
// ...
 
$output = node_view($node, FALSE, TRUE);

  if (
function_exists('comment_render') && $node->comment) {
   
$output .= comment_render($node, $cid);
  }
 
// ...
 
return $output;
}
?>

So removing it would (a) change the functions parameters above, and (b) not save much code. In any case, removing it seems like a seperate issue - this issue is about a test-case: as long as the code is present, the test is valid, right? The testcase will (correctly) trip up if someone removes the code, and can be fixed then.

#14

lyricnz - September 10, 2008 - 03:39
Status:patch (to be ported)» reviewed & tested by the community

Oops, didn't mean to change status

#15

lyricnz - September 10, 2008 - 13:08

Re-roll, post #302396: Make tests more granular. 484 passes, 0 fails, 0 exceptions.

AttachmentSizeStatusTest resultOperations
individual-comment.test.patch1.84 KBIgnoredNoneNone

#16

webchick - September 19, 2008 - 03:12
Status:reviewed & tested by the community» fixed

Yeah, I agree that while this code exists, we should probably write tests for it, and the question of whether or not it's truly dead (I could see the use case for "permalinking" to a comment, maybe...) taken up in a separate issue. lyricnz's research into it in #13 makes it a bit muddy as to whether we'd actually be saving anything or not.

Test looks good. Committed to HEAD. Thanks!

#17

Anonymous (not verified) - October 3, 2008 - 03:22
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.