1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
<?php
// $Id$
class TrackerTest extends DrupalWebTestCase {
protected $user;
protected $other_user;
protected $new_node;
public static function getInfo() {
return array(
'name' => 'Tracker',
'description' => 'Create nodes and check for their display in the tracker listings.',
'group' => 'Tracker'
);
}
function setUp() {
parent::setUp('comment', 'tracker');
$permissions = array('access comments', 'create page content', '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(8),
'status' => 1,
);
$page2 = array(
'title' => $this->randomName(8),
'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.'));
$this->assertLink(t('My recent posts'), 0, t('User tab shows up on the global tracker page.'));
}
/**
* Test the presence of nodes on a user's tracker listing.
*/
function testTrackerUser() {
$this->drupalLogin($this->user);
$page1 = array(
'title' => $this->randomName(8),
'uid' => $this->user->uid,
'status' => 1,
);
$page2 = array(
'title' => $this->randomName(8),
'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),
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell a difference, so 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', t('New comments are counted on the tracker listing pages.'));
}
}
|