You are here

function UserpointsNodeCommentTestCase::verifyPublishingAuthorChange in User points Nodes and Comments 7

Create a published node, unpublish and change author and publish again.

1 call to UserpointsNodeCommentTestCase::verifyPublishingAuthorChange()
UserpointsNodeCommentTestCase::testCreateContent in ./userpoints_nc.test

File

./userpoints_nc.test, line 140
Tests for userpoints_nc.module

Class

UserpointsNodeCommentTestCase
@file Tests for userpoints_nc.module

Code

function verifyPublishingAuthorChange() {
  $content = array(
    'title' => $this
      ->randomName(10),
  );
  $this
    ->drupalPost('node/add/' . $this->type['type'], $content, t('Save'));
  $this
    ->assertText(t('@name @title has been created.', array(
    '@name' => $this->type['name'],
    '@title' => $content['title'],
  )));
  $this
    ->assertText(t('You just earned 5 points and now have 5 points in the General category.'));

  // Verify point total.
  $this
    ->assertEqual(userpoints_get_current_points($this->admin->uid), 5);
  $this
    ->assertEqual(userpoints_get_current_points($this->user->uid), 0);
  $this
    ->clickLink(t('Edit'));
  $edit_content = array(
    'status' => FALSE,
    'name' => $this->user->name,
  );
  $this
    ->drupalPost(NULL, $edit_content, t('Save'));
  $this
    ->assertText(t('@name @title has been updated.', array(
    '@name' => $this->type['name'],
    '@title' => $content['title'],
  )));
  $this
    ->assertText(t('You just had 5 points deducted and now have 0 points in the General category.'));

  // Verify point total.
  $this
    ->assertEqual(userpoints_get_current_points($this->admin->uid), 0);
  $this
    ->assertEqual(userpoints_get_current_points($this->user->uid), 0);
  $this
    ->clickLink(t('Edit'));
  $edit_content = array(
    'status' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit_content, t('Save'));
  $this
    ->assertText(t('@name @title has been updated.', array(
    '@name' => $this->type['name'],
    '@title' => $content['title'],
  )));
  $this
    ->assertText(t('@user just earned 5 points and now has 5 points in the General category.', array(
    '@user' => $this->user->name,
  )));

  // Verify point total.
  $this
    ->assertEqual(userpoints_get_current_points($this->admin->uid), 0);
  $this
    ->assertEqual(userpoints_get_current_points($this->user->uid), 5);
}