You are here

public function AnswersTestCase::testAnswerWithNoBody in Answers 7.3

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

Tests body is required on answers_answer.

File

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

Class

AnswersTestCase
Tests the functionality of the answers module.

Code

public function testAnswerWithNoBody() {
  $langcode = LANGUAGE_NONE;
  $user2 = $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');
  $answer = array();
  $answer["title"] = '';
  $answer["body[{$langcode}][0][value]"] = "";
  $this
    ->drupalPost('node/add/answer/1', $answer, 'Post Your Answer');
  $this
    ->assertRaw('<div class="messages error">
<h2 class="element-invisible">Error message</h2>
Answer field is required.</div>', 'Body field is required');
}