You are here

function UserpointsTestCase::testGetDefaultTid in User Points 6

File

tests/userpoints_api.test, line 361

Class

UserpointsTestCase

Code

function testGetDefaultTid() {
  $vid = userpoints_get_vid();
  $term_name = $this
    ->randomName(10);
  $desc = $this
    ->randomName(10);

  /* create a new term*/
  $term = array(
    'name' => $term_name,
    'description' => $desc,
    'vid' => $vid,
  );
  taxonomy_save_term($term);

  /* login as admin userpoints */
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer userpoints',
  ));
  $this
    ->drupalLogin($admin_user);

  /* save settings */
  $edit = array(
    'userpoints_category_default_tid' => $term['tid'],
  );
  $this
    ->drupalPost('admin/settings/userpoints', $edit, 'Save configuration');

  /* check API*/
  $tid = userpoints_get_default_tid();
  $this
    ->assertTrue($tid == $term['tid'], t("Successfully retrieved default tid = %d.", array(
    '%d' => $tid,
  )));

  /* check API*/
  $api_vid = userpoints_get_vid();
  $this
    ->assertEqual($api_vid, $vid, t("Successfully retrieved default vid %d.", array(
    '%d' => $vid,
  )));
}