You are here

function UserpointsNodeVisitsTestCase::testVisitingContent in User points Nodes and Comments 7

Prepare test environment, run different test methods.

File

userpoints_nc_visits/userpoints_nc_visits.test, line 42

Class

UserpointsNodeVisitsTestCase
Generic tests for Userpoints Visits module.

Code

function testVisitingContent() {
  $this->admin = $this
    ->drupalCreateUser(array(
    'view userpoints',
    'view own userpoints',
    'bypass node access',
    'administer nodes',
    'administer userpoints',
    'administer content types',
  ));
  $this->user1 = $this
    ->drupalCreateUser(array(
    'userpoints nc track visits',
  ));
  $this->user2 = $this
    ->drupalCreateUser(array(
    'userpoints nc track visits',
  ));
  $this
    ->drupalLogin($this->admin);
  $this->type = array(
    'name' => $this
      ->randomName(10),
    'type' => strtolower($this
      ->randomName(5)),
    'userpoints_nc_visits_points' => 2,
  );
  $this
    ->drupalPost('admin/structure/types/add', $this->type, t('Save content type'));
  $this
    ->assertText(t('The content type @name has been added.', array(
    '@name' => $this->type['name'],
  )));
  node_types_rebuild();
  menu_rebuild();

  // Reset permissions so that permissions for this content type are available.
  $this
    ->checkPermissions(array(), TRUE);
  user_role_grant_permissions(4, array(
    'create ' . $this->type['type'] . ' content',
    'edit any ' . $this->type['type'] . ' content',
  ));
  $this
    ->verifyAllContent();
  $this
    ->deletePoints();
  $this
    ->drupalLogin($this->admin);
  $this
    ->verifyFirstContentOnly();
}