You are here

function ActivityAPITest::testGetActivity1 in Activity 5.4

Same name and namespace in other branches
  1. 5.3 tests/ActivityAPITests.test \ActivityAPITest::testGetActivity1()
  2. 6 tests/ActivityAPITests.test \ActivityAPITest::testGetActivity1()

Test activity_get_activity activity_get_activity($uids = ACTIVITY_ALL, $filters = NULL, $limit = NULL, $tablesort_headers = NULL)

Assert that function can take a uid or an array of uids Can take an optional array of filters to filter the results Takes a limit parameter Support HTML tables with tablesort query additions Should always return an array, even if empty. array items shall be ordered by database so that tablesort queries are possible.

File

tests/ActivityAPITests.test, line 93

Class

ActivityAPITest

Code

function testGetActivity1() {

  // Does this function exist?
  $this
    ->assertTrue(function_exists('activity_get_activity'));

  // Make a new user to test with
  $tester = $this
    ->drupalCreateUserRolePerm();

  // Create some activity
  $module = 'simpletest';
  $type = 'testing';
  $operation = 'insert';
  $data = array(
    'dummydata' => 'foobar',
  );
  $target_users_roles = array(
    ACTIVITY_ALL => 'All',
    $tester->uid => 'Author',
    '4711' => 'Court Jester',
    '4712' => 'King of Spades',
  );
  $aid = activity_insert($module, $type, $operation, $data, $target_users_roles);

  // Assert that each of the following only returns the one activity we inserted.
  $activities[1] = activity_get_activity($tester->uid);
  $activities[2] = activity_get_activity(array(
    $tester->uid,
  ));
  $activities[3] = activity_get_activity(array(
    $tester->uid,
    999999,
  ));
  $activities[4] = activity_get_activity(array(
    $tester->uid,
  ), array(
    'module' => $module,
  ));
  $activities[5] = activity_get_activity($tester->uid, NULL, 40);
  foreach ($activities as $key => $activity) {
    $this
      ->assertEqual($aid, $activity[0]['aid'], $key . ': %s ' . t('Expecting aid to be @aid. Found @activity_id.', array(
      '@aid' => $aid,
      '@activity_id' => $activity[0]['aid'],
    )));
  }
}