function UserpointsNodeVisitsTestCase::verifyAllContent in User points Nodes and Comments 7
Verify that points are granted correctly if set to 'All content'.
1 call to UserpointsNodeVisitsTestCase::verifyAllContent()
- UserpointsNodeVisitsTestCase::testVisitingContent in userpoints_nc_visits/
userpoints_nc_visits.test - Prepare test environment, run different test methods.
File
- userpoints_nc_visits/
userpoints_nc_visits.test, line 83
Class
- UserpointsNodeVisitsTestCase
- Generic tests for Userpoints Visits module.
Code
function verifyAllContent() {
$edit = array(
'userpoints_nc_visits_limit' => 'all',
);
$this
->drupalPost('admin/config/people/userpoints/settings', $edit, t('Save configuration'));
$content = array(
'title' => $this
->randomName(10),
);
$this
->drupalPost('node/add/' . $this->type['type'], $content, t('Save'));
$this
->assertText(t('@name @title has been created.', array(
'@name' => $this->type['name'],
'@title' => $content['title'],
)));
preg_match('|node/(\\d+)|', $this
->getUrl(), $matches);
$nid1 = $matches[1];
$content = array(
'title' => $this
->randomName(10),
);
$this
->drupalPost('node/add/' . $this->type['type'], $content, t('Save'));
$this
->assertText(t('@name @title has been created.', array(
'@name' => $this->type['name'],
'@title' => $content['title'],
)));
preg_match('|node/(\\d+)|', $this
->getUrl(), $matches);
$nid2 = $matches[1];
// Verify point total, admin should not yet have any points.
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 0);
// Log in as user 1, visit content.
$this
->drupalLogin($this->user1);
$this
->drupalGet('node/' . $nid1);
// Verify point total.
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 2);
// Visit again, points should not have been updated.
$this
->drupalGet('node/' . $nid1);
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 2);
// Visit second node, points should update now.
$this
->drupalGet('node/' . $nid2);
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 4);
// Log in as second user, visit second node, points should go up.
$this
->drupalLogin($this->user2);
$this
->drupalGet('node/' . $nid2);
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 6);
// Visit first node, points should go up.
$this
->drupalGet('node/' . $nid1);
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 8);
// Visit second node again, points should not go up.
$this
->drupalGet('node/' . $nid2);
$this
->assertEqual(userpoints_get_current_points($this->admin->uid), 8);
}