You are here

public function AnswersUserPointsTestCase::testDownVoteAnswer in Answers 7.4

Test DownVoting an Answer.

File

answers_userpoints/answers_userpoints.test, line 169
Tests for answers_userpoints.module.

Class

AnswersUserPointsTestCase
Tests the functionality of the answers_userpoints module admin settings.

Code

public function testDownVoteAnswer() {
  $langcode = LANGUAGE_NONE;
  $this
    ->drupalLogin($this->questionUser);
  $this
    ->drupalGet('node/add/answers-question');
  $question = array();
  $question['title'] = 'Woodchucks';
  $question["body[{$langcode}][0][value]"] = "How much wood could a woodchuck chuck?";
  $this
    ->drupalPost('node/add/answers-question', $question, 'Save');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->answerUser);
  $this
    ->drupalGet('node/1');
  $answer = array();
  $answer["body[{$langcode}][0][value]"] = "42 cords of wood.";
  $this
    ->drupalPost('node/1', $answer, 'Save');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->questionUser);
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('-1', 0, 'DownVote Answer');
  $this
    ->assertEqual(-1, userpoints_get_current_points($this->questionUser->uid), 'voter\'s points = ' . userpoints_get_current_points($this->questionUser->uid));
  $this
    ->assertEqual(-2, userpoints_get_current_points($this->answerUser->uid), 'Answer author\'s points = ' . userpoints_get_current_points($this->answerUser->uid));
  $this
    ->clickLink('-1', 0, 'Cancel DownVote Answer');
  $this
    ->assertEqual(0, userpoints_get_current_points($this->questionUser->uid), 'voter\'s points = ' . userpoints_get_current_points($this->questionUser->uid));
  $this
    ->assertEqual(0, userpoints_get_current_points($this->answerUser->uid), 'Answer author\'s points = ' . userpoints_get_current_points($this->answerUser->uid));
}