function UserpointsBaseTestCase::verifyPoints in User Points 7.2
Same name and namespace in other branches
- 7 tests/userpoints_api.test \UserpointsBaseTestCase::verifyPoints()
Verify the current and optionally max points in a specific category.
Parameters
$uid: User uid for the user that needs to be tested.
$current: The amount of points the user is currently supposed to have.
$max: The amount of max points of the user. Only tested if not NULL.
$tid: The category that needs to be checked. Default is used is none is provided.
1 call to UserpointsBaseTestCase::verifyPoints()
- UserpointsGrantPointsTestCase::testGrantPoints in ./
userpoints.test - Test basic usage of the API to create and update transactions.
File
- ./
userpoints.test, line 61 - Contains test classes for userpoints module.
Class
- UserpointsBaseTestCase
- Userpoints base test class with various helper functions.
Code
function verifyPoints($uid, $current, $max = NULL, $tid = NULL) {
// Check if a term id is passed as a parameter.
if (!$tid) {
// It is not, so get the default term id.
$tid = userpoints_get_default_tid();
}
$api_current = userpoints_get_current_points($uid, $tid);
$this
->assertEqual($current, $api_current, t('Current points for tid %tid are correct (expected: %expected, actual: %actual).', array(
'%expected' => $current,
'%actual' => $api_current,
'%tid' => $tid,
)));
if ($max !== NULL) {
// Hijack static cache, delete this item from it.
$max_cache =& drupal_static('userpoints_get_max_points', array());
unset($max_cache[$uid][$tid]);
$api_max = userpoints_get_max_points($uid, $tid);
$this
->assertEqual($max, $api_max, t('Max points for tid %tid are correct (expected: %expected, actual: %actual).', array(
'%expected' => $max,
'%actual' => $api_max,
'%tid' => $tid,
)));
}
}