You are here

public function AnswersViewTestCase::testOwnAnswersView in Answers 7.4

Same name and namespace in other branches
  1. 7.3 answers.test \AnswersViewTestCase::testOwnAnswersView()

Test Own Answers view page.

File

./answers.test, line 358
Tests for answers.module.

Class

AnswersViewTestCase
Tests the functionality of the answers module views.

Code

public function testOwnAnswersView() {
  $langcode = LANGUAGE_NONE;
  $user2 = $this
    ->drupalCreateUser();
  $user3 = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($user2);
  $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');
  $answer = array();
  $answer["body[{$langcode}][0][value]"] = "Woodchucks do not chuck wood.";
  $this
    ->drupalPost('node/1', $answer, 'Save');
  $this
    ->drupalGet('node/add/answers-question');
  $question = array();
  $question['title'] = 'Woodchucks are young werewolves?';
  $question["body[{$langcode}][0][value]"] = "Are woodchuck really just werewolves in disguise?";
  $this
    ->drupalPost('node/add/answers-question', $question, 'Save');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($user3);
  $this
    ->drupalGet('node/1');
  $answer["body[{$langcode}][0][value]"] = "Exactly 42 cords of wood.";
  $this
    ->drupalPost('node/1', $answer, 'Save');
  $this
    ->drupalGet('node/add/answers-question');
  $question = array();
  $question['title'] = 'Is it true?';
  $question["body[{$langcode}][0][value]"] = "Is what they say about Woodchuck true?";
  $this
    ->drupalPost('node/add/answers-question', $question, 'Save');
  $this
    ->drupalGet('user/3/answers');
  $this
    ->assertLink('Woodchucks');
  $this
    ->assertNoLink('Is it true?');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('node/5');
  $answer = array();
  $answer["body[{$langcode}][0][value]"] = "Woodchucks are clearly smaller werewolves. They were sent to infiltrate and spy on our society until the invasion.";
  $this
    ->drupalPost('node/5', $answer, 'Save');
  $this
    ->drupalGet('user/2/answers');
  $this
    ->assertLink('Woodchucks');
  $this
    ->assertNoLink('Woodchucks are young werewolves?');
  $this
    ->assertLink('Is it true?');
}