function TrackerTest::testTrackerUser
Same name in other branches
- 9 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerUser()
- 8.9.x core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerUser()
- 10 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerUser()
- 11.x core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerUser()
Tests for the presence of nodes on a user's tracker listing.
File
-
modules/
tracker/ tracker.test, line 75
Class
- TrackerTest
- Defines a base class for testing tracker.module.
Code
function testTrackerUser() {
$this->drupalLogin($this->user);
$unpublished = $this->drupalCreateNode(array(
'title' => $this->randomName(8),
'uid' => $this->user->uid,
'status' => 0,
));
$my_published = $this->drupalCreateNode(array(
'title' => $this->randomName(8),
'uid' => $this->user->uid,
'status' => 1,
));
$other_published_no_comment = $this->drupalCreateNode(array(
'title' => $this->randomName(8),
'uid' => $this->other_user->uid,
'status' => 1,
));
$other_published_my_comment = $this->drupalCreateNode(array(
'title' => $this->randomName(8),
'uid' => $this->other_user->uid,
'status' => 1,
));
$comment = array(
'subject' => $this->randomName(),
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
$this->drupalGet('user/' . $this->user->uid . '/track');
$this->assertNoText($unpublished->title, "Unpublished nodes do not show up in the users's tracker listing.");
$this->assertText($my_published->title, "Published nodes show up in the user's tracker listing.");
$this->assertNoText($other_published_no_comment->title, "Other user's nodes do not show up in the user's tracker listing.");
$this->assertText($other_published_my_comment->title, "Nodes that the user has commented on appear in the user's tracker listing.");
// Verify that unpublished comments are removed from the tracker.
$admin_user = $this->drupalCreateUser(array(
'administer comments',
'access user profiles',
));
$this->drupalLogin($admin_user);
$this->drupalPost('comment/1/edit', array(
'status' => COMMENT_NOT_PUBLISHED,
), t('Save'));
$this->drupalGet('user/' . $this->user->uid . '/track');
$this->assertNoText($other_published_my_comment->title, 'Unpublished comments are not counted on the tracker listing.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.