143 lines
4.3 KiB
Plaintext
143 lines
4.3 KiB
Plaintext
<?php
|
|
// $Id$
|
|
|
|
class TrackerTest extends DrupalWebTestCase {
|
|
protected $user;
|
|
protected $other_user;
|
|
protected $new_node;
|
|
|
|
/**
|
|
* Implementation of getInfo().
|
|
*/
|
|
function getInfo() {
|
|
return array(
|
|
'name' => t('Tracker'),
|
|
'description' => t('Create nodes and check for their display in the tracker listings.'),
|
|
'group' => t('Tracker')
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implementation of setUp().
|
|
*/
|
|
function setUp() {
|
|
parent::setUp('comment', 'tracker');
|
|
|
|
$permissions = array('access comments', 'post comments', 'post comments without approval');
|
|
$this->user = $this->drupalCreateUser($permissions);
|
|
$this->other_user = $this->drupalCreateUser($permissions);
|
|
}
|
|
|
|
/**
|
|
* Test the presence of nodes on the global tracker listing.
|
|
*/
|
|
function testTrackerAll() {
|
|
$this->drupalLogin($this->user);
|
|
|
|
$page1 = array(
|
|
'title' => $this->randomName(4, 'published_'),
|
|
'status' => 1,
|
|
);
|
|
$page2 = array(
|
|
'title' => $this->randomName(4, 'unpublished_'),
|
|
'status' => 0,
|
|
);
|
|
$this->drupalCreateNode($page1);
|
|
$this->drupalCreateNode($page2);
|
|
|
|
$this->drupalGet('tracker');
|
|
$this->assertText($page1['title'], t('Nodes show up in the tracker listing.'));
|
|
$this->assertNoText($page2['title'], t('Unpublished nodes do not show up in the tracker listing.'));
|
|
}
|
|
|
|
/**
|
|
* Test the presence of nodes on a user's tracker listing.
|
|
*/
|
|
function testTrackerUser() {
|
|
$this->drupalLogin($this->user);
|
|
|
|
$page1 = array(
|
|
'title' => $this->randomName(4, 'published_'),
|
|
'uid' => $this->user->uid,
|
|
'status' => 1,
|
|
);
|
|
$page2 = array(
|
|
'title' => $this->randomName(4, 'unpublished_'),
|
|
'uid' => $this->user->uid,
|
|
'status' => 0,
|
|
);
|
|
$this->drupalCreateNode($page1);
|
|
$this->drupalCreateNode($page2);
|
|
|
|
$this->drupalGet('user/' . $this->user->uid . '/track');
|
|
$this->assertText($page1['title'], t("Nodes show up in the author's tracker listing."));
|
|
$this->assertNoText($page2['title'], t("Unpublished nodes do not show up in the author's tracker listing."));
|
|
}
|
|
|
|
/**
|
|
* Test the presence of the "new" flag for nodes.
|
|
*/
|
|
function testTrackerNewNodes() {
|
|
$this->drupalLogin($this->user);
|
|
|
|
$edit = array(
|
|
'title' => $this->randomName(),
|
|
);
|
|
$node = $this->drupalCreateNode($edit);
|
|
|
|
$this->drupalGet('tracker');
|
|
$this->assertPattern('/' . $edit['title'] . '.*new/', t('New nodes are flagged as such in the tracker listing.'));
|
|
|
|
$this->drupalGet('node/' . $node->nid);
|
|
$this->drupalGet('tracker');
|
|
$this->assertNoPattern('/' . $edit['title'] . '.*new/', t('Visited nodes are not flagged as new.'));
|
|
|
|
$this->drupalLogin($this->other_user);
|
|
$this->drupalGet('tracker');
|
|
$this->assertPattern('/' . $edit['title'] . '.*new/', t('For another user, new nodes are flagged as such in the tracker listing.'));
|
|
|
|
$this->drupalGet('node/' . $node->nid);
|
|
$this->drupalGet('tracker');
|
|
$this->assertNoPattern('/' . $edit['title'] . '.*new/', t('For another user, visited nodes are not flagged as new.'));
|
|
}
|
|
|
|
/**
|
|
* Test comment counters on the tracker listing.
|
|
*/
|
|
function testTrackerNewComments() {
|
|
// Make node preview optional
|
|
variable_set('comment_preview_page', 0);
|
|
|
|
$this->drupalLogin($this->user);
|
|
|
|
$edit = array(
|
|
'comment' => 2,
|
|
'title' => $this->randomName(),
|
|
);
|
|
$node = $this->drupalCreateNode($edit);
|
|
|
|
// Add a comment to the page.
|
|
$comment = array(
|
|
'subject' => $this->randomName(),
|
|
'comment' => $this->randomName(20),
|
|
);
|
|
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); // The new comment is automatically viewed by the current user.
|
|
|
|
$this->drupalLogin($this->other_user);
|
|
$this->drupalGet('tracker');
|
|
$this->assertText('1 new', t('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' => $this->randomName(20),
|
|
);
|
|
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
|
|
|
|
$this->drupalLogin($this->user);
|
|
$this->drupalGet('tracker');
|
|
$this->assertText('1 new', t('New comments are counted on the tracker listing pages.'));
|
|
}
|
|
}
|