function VoteUpDownTestCase::testVoteDown in Vote Up/Down 6
Check the permissions for voting only down
File
- tests/
vote_up_down.test, line 320 - Test file for Vote Up/Down.
Class
Code
function testVoteDown() {
// Enable Vote Up/Down for Story node types. Everything else should be
// default settings.
$this
->drupalLogin($this->admin_user);
$edit = array(
'vote_up_down_node_types[story]' => TRUE,
);
$this
->drupalPost('admin/settings/voteupdown', $edit, 'Save configuration');
$this
->assertText('The configuration options have been saved.');
$this
->assertText('Vote Up/Down');
// Create another user to test the vote up only permission
$this->votedown_user = $this
->drupalCreateUser(array(
'access vote up/down statistics',
'use vote down',
'view up/down votes',
'create story content',
));
// Login
$this
->drupalLogin($this->votedown_user);
//Create another story
$node = array(
'title' => $this
->randomName(20, 'NODE_'),
'body' => $this
->randomName(20, 'BODY_'),
);
$this
->drupalPost('node/add/story', $node, 'Save');
$this
->assertText("Story {$node['title']} has been created.");
// Check the presence of the widget
$this
->assertText('0 points');
$this
->assertRaw('<div class="vote-up-down-widget">');
$node_url = $this
->getUrl();
$this
->assertText('Voting details', 'Voting details tab is on node pages');
// Use the url to find the NID, and then check for the <span> tag that the
// JavaScript uses to update the points.
preg_match('#node/([0-9]*)$#', $node_url, $matches);
$nid = $matches[1];
$this
->assertRaw('<span id="vote_points_' . $nid . '" class="vote-points">', 'Labeled SPAN tag found');
// Check empty Voting details about this node.
$this
->clickLink('Voting details');
// Bug #360139
$this
->assertNoRaw('<td>', 'Voting Details Records found on new Story node');
// Back to the node page and check that the user can only vote up and cannot vote down
$this
->drupalGet($node_url);
$this
->assertRaw('<span id="vote_up_1" class="up-inact" title="You have no privileges to vote up."></span>', t('Make sure the vote up is disabled.'));
$this
->assertNoRaw('<span title="You have no privileges to vote down." class="down-inact" id="vote_down_1"/>', t('Make sure the vote down is not disabled.'));
// Cast a vote, and make sure the score was updated.
$this
->castVote(FALSE);
$this
->assertText('-1 point');
$this
->clickLink('Voting details');
$this
->assertText($this->votedown_user->name);
$this
->assertRaw('<td>-1</td>');
}