function TrackerTest::testTrackerNewComments
7.x tracker.test | TrackerTest::testTrackerNewComments() |
Tests for comment counters on the tracker listing.
File
- drupal-7.x/
modules/ tracker/ tracker.test, line 149 - Tests for tracker.module.
Class
- TrackerTest
- Defines a base class for testing tracker.module.
Code
function testTrackerNewComments() {
$this->drupalLogin($this->user);
$node = $this->drupalCreateNode(array(
'comment' => 2,
'title' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(8)))),
));
// Add a comment to the page.
$comment = array(
'subject' => $this->randomName(),
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
// The new comment is automatically viewed by the current user.
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
$this->drupalLogin($this->other_user);
$this->drupalGet('tracker');
$this->assertText('1 new', 'New comments are counted on the tracker listing pages.');
$this->drupalGet('node/' . $node->nid);
// Add another comment as other_user.
$comment = array(
'subject' => $this->randomName(),
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell the difference, so we wait one second here.
sleep(1);
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
$this->drupalLogin($this->user);
$this->drupalGet('tracker');
$this->assertText('1 new', 'New comments are counted on the tracker listing pages.');
}