Commit 29f4a2d9 authored by webchick's avatar webchick

Issue #983632 by peterpoe, marcingy, catch: Fixed 'New' comment marker does not work.

parent b8b42794
......@@ -251,6 +251,56 @@ class CommentHelperCase extends DrupalWebTestCase {
return $match[2];
}
/**
* Tests new comment marker.
*/
public function testCommentNewCommentsIndicator() {
// Test if the right links are displayed when no comment is present for the
// node.
$this->drupalLogin($this->admin_user);
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN));
$this->drupalGet('node');
$this->assertNoLink(t('@count comments', array('@count' => 0)));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$this->assertLink(t('Read more'));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 1, t('One child found'));
// Create a new comment. This helper function may be run with different
// comment settings so use comment_save() to avoid complex setup.
$comment = (object) array(
'cid' => NULL,
'nid' => $this->node->nid,
'node_type' => $this->node->type,
'pid' => 0,
'uid' => $this->loggedInUser->uid,
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => ip_address(),
'language' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
);
comment_save($comment);
$this->drupalLogout();
// Log in with 'web user' and check comment links.
$this->drupalLogin($this->web_user);
$this->drupalGet('node');
$this->assertLink(t('1 new comment'));
$this->clickLink(t('1 new comment'));
$this->assertRaw('<a id="new"></a>', t('Found "new" marker.'));
$this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));
// Test if "new comment" link is correctly removed.
$this->drupalGet('node');
$this->assertLink(t('1 comment'));
$this->assertLink(t('Read more'));
$this->assertNoLink(t('1 new comment'));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 2, print_r($count, TRUE));
}
}
class CommentInterfaceTest extends CommentHelperCase {
......
......@@ -1404,11 +1404,13 @@ function node_show($node, $message = FALSE) {
drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
}
// For markup consistency with other pages, use node_view_multiple() rather than node_view().
$nodes = node_view_multiple(array($node->nid => $node), 'full');
// Update the history table, stating that this user viewed this node.
node_tag_new($node);
// For markup consistency with other pages, use node_view_multiple() rather than node_view().
return node_view_multiple(array($node->nid => $node), 'full');
return $nodes;
}
/**
......
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