You are here

public function AnswersViewTestCase::testOwnQuestionsView in Answers 7.4

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

Test Own Questions view page.

File

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

Class

AnswersViewTestCase
Tests the functionality of the answers module views.

Code

public function testOwnQuestionsView() {
  $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');
  $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 = array();
  $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/questions');
  $this
    ->assertNoLink('Woodchucks');
  $this
    ->assertNoLink('Woodchucks are young werewolves?');
  $this
    ->assertLink('Is it true?');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('user/2/questions');
  $this
    ->assertLink('Woodchucks');
  $this
    ->assertLink('Woodchucks are young werewolves?');
}