function UserpointsBaseTestCase::addPoints in User Points 7.2
Same name and namespace in other branches
- 7 tests/userpoints_api.test \UserpointsBaseTestCase::addPoints()
Add points through the admin form.
Parameters
$points: Amount of points to add.
$user: User object for which to grant points for.
$total: Amount of points the user should have after the points have been added. If not NULL, the confirmation string is checked and so is userpoints_get_current_points().
Return value
The most recent transaction id, assuming that this belongs to this transaction.
4 calls to UserpointsBaseTestCase::addPoints()
- UserpointsAdminTestCase::testAddEditPoints in ./
userpoints.test - UserpointsAPITestCase::testUserpermissions in ./
userpoints.test - Test user permissions
- UserpointsAPITestCase::testUserTransactionLinksPermissions in ./
userpoints.test - Test user transactions links permissions on users profile.
- UserpointsAPITestCase::testUserTransactionPermissions in ./
userpoints.test - Test user userpoints transactions permissions
File
- ./
userpoints.test, line 32 - Contains test classes for userpoints module.
Class
- UserpointsBaseTestCase
- Userpoints base test class with various helper functions.
Code
function addPoints($points, $user, $total = NULL, $additional = array()) {
$edit = array(
'txn_user' => $user->name,
'points' => $points,
) + $additional;
$this
->drupalPost('admin/config/people/userpoints/add', $edit, t('Save'));
if ($total !== NULL) {
$categories = userpoints_get_categories();
$tid = userpoints_get_default_tid();
$category = $categories[$tid];
$this
->assertText(t('@name just earned @points points and now has @total points in the @category category.', array(
'@name' => $user->name,
'@points' => $points,
'@total' => $total,
'@category' => $category,
)), t('Correct confirmation message displayed.'));
$this
->assertEqual($total, userpoints_get_current_points($user->uid, $tid), t('User has the correct total amount of points.'));
}
return db_query('SELECT MAX(txn_id) FROM {userpoints_txn} WHERE uid = :uid', array(
':uid' => $user->uid,
))
->fetchField();
}