You are here

function UserpointsAPITestCase::getTxnPoints in User Points 7

Same name and namespace in other branches
  1. 7.2 userpoints.test \UserpointsAPITestCase::getTxnPoints()

Returns the user points of a specific transaction.

Parameters

$uid: User uid for which the points should be selected.

$points: Optionaly define which transaction should be loaded by specifying the points.

$sum: If TRUE, calculate the sum of all matching transaction rows.

Return value

Amount of points according to the arguments.

4 calls to UserpointsAPITestCase::getTxnPoints()
UserpointsAPITestCase::testBasicCall in tests/userpoints_api.test
Call userpoints_userpointsapi() with just points.
UserpointsAPITestCase::testExpiration in tests/userpoints_api.test
UserpointsAPITestCase::testModeration in tests/userpoints_api.test
UserpointsAPITestCase::testUserpermissions in tests/userpoints_api.test
Test user permissions

File

tests/userpoints_api.test, line 128
Contains test classes for userpoints module.

Class

UserpointsAPITestCase
API Tests.

Code

function getTxnPoints($uid, $points = NULL, $sum = FALSE) {
  $query = db_select('userpoints_txn', 'p');
  if ($sum) {
    $query
      ->addExpression('SUM(points)');
  }
  else {
    $query
      ->addField('p', 'points');
  }
  $query
    ->condition('uid', $uid);
  if ($points) {
    $query
      ->condition('points', $points);
  }
  return (int) $query
    ->execute()
    ->fetchField();
}