You are here

public function AnswersViewTestCase::testOwnQuestionsView in Answers 7.3

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

Test Own Questions view page.

File

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

Class

AnswersViewTestCase
Tests the functionality of the answers module views.

Code

public function testOwnQuestionsView() {
  $langcode = LANGUAGE_NONE;
  $user2 = $this
    ->drupalCreateUser(array(
    'administer content types',
    'create question content',
    'edit own question content',
    'create answer content',
    'edit own answer content',
  ));
  $user3 = $this
    ->drupalCreateUser(array(
    'administer content types',
    'create question content',
    'edit own question content',
    'create answer content',
    'edit own answer content',
  ));
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('node/add/question');
  $question = array();
  $question['title'] = 'Woodchucks';
  $question["body[{$langcode}][0][value]"] = "How much wood could a woodchuck chuck?";
  $this
    ->drupalPost('node/add/question', $question, 'Ask Your Question');
  $this
    ->drupalGet('node/add/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/question', $question, 'Ask Your Question');
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($user3);
  $this
    ->drupalGet('node/1');
  $answer = array();
  $answer["body[{$langcode}][0][value]"] = "Exactly 42 cords of wood.";
  $this
    ->drupalPost('node/add/answer/1', $answer, 'Post Your Answer');
  $this
    ->drupalGet('node/add/question');
  $question = array();
  $question['title'] = 'Is it true?';
  $question["body[{$langcode}][0][value]"] = "Is what they say about Woodchuck true?";
  $this
    ->drupalPost('node/add/question', $question, 'Ask Your Question');
  $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?');
}