function UserpointsTestCase::testModeration in User Points 6
File
- tests/userpoints_api.test, line 454
Class
- UserpointsTestCase
Code
function testModeration() {
global $user;
$points = rand(1, 100);
$params = array(
'uid' => $user->uid,
'points' => $points,
'moderate' => TRUE,
);
$return = userpoints_userpointsapi($params);
$this
->assertTrue($return['status'] == TRUE, t("1. (moderate=TRUE) API responded with successful grant of points"));
$sql = "SELECT points FROM {userpoints_txn} WHERE uid = %d AND points = %d AND status = 1";
$db_points = (int) db_result(db_query($sql, $user->uid, $points));
$this
->assertTrue($db_points == $points, t("1. (moderate=TRUE) Successfully verified points in the txn table and waiting moderation."));
$sql1 = "SELECT points FROM {userpoints} WHERE uid=%d";
$db_points = (int) db_result(db_query($sql1, $user->uid));
$this
->assertTrue($db_points == 0, t("1. (moderate=TRUE) Successfully verified that points were added and the summary table was not updated."));
$params = array(
'uid' => $user->uid,
'points' => $points,
'moderate' => FALSE,
);
$return = userpoints_userpointsapi($params);
$this
->assertTrue($return['status'] == TRUE, t("7. (moderate=FALSE) API responded with successful grant of points"));
$sql = "SELECT points FROM {userpoints_txn} WHERE uid = %d AND points = %d AND status = 0";
$db_points = (int) db_result(db_query($sql, $user->uid, $points));
$this
->assertTrue($db_points == $points, t("7. (moderate=FALSE) Successfully verified points in the txn table and NOT waiting moderation."));
}