Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
756131a8
Commit
756131a8
authored
16 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#239455
by boombatower, flobruit, dmitrig01: tracker module tests.
parent
0daa3e90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/tracker/tracker.test
+145
-0
145 additions, 0 deletions
modules/tracker/tracker.test
with
145 additions
and
0 deletions
modules/tracker/tracker.test
0 → 100644
+
145
−
0
View file @
756131a8
<?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
();
$this
->
drupalModuleEnable
(
'comment'
);
$this
->
drupalModuleEnable
(
'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.'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment