You are here

public function AnswersTestCase::testLabels in Answers 7.4

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

Check node labels.

File

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

Class

AnswersTestCase
Tests the functionality of the answers module.

Code

public function testLabels() {
  $langcode = LANGUAGE_NONE;
  $this
    ->drupalLogin($this->answersUser);
  $this
    ->drupalGet('node/add/answers-question');
  $this
    ->assertResponse(200);
  $this
    ->assertTitle(t('Create Question | Drupal'), 'The title on the create answer_question page is "Create Question | Drupal".');
  $this
    ->assertRaw('<label for="edit-title">Title <span class="form-required" title="This field is required.">*</span></label>', 'The question title is Title');
  $this
    ->assertRaw('<label for="edit-body-und-0-value">Body </label>', 'The question body is Body');
  $this
    ->assertFieldByName('title', '', 'The title field exists');
  $this
    ->assertFieldByName("body[{$langcode}][0][value]", '', 'The body field exists');
  $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
    ->assertRaw('<h2 class="new-answer-form-title">Your Answer</h2>', 'Answers Form exists');
  $this
    ->assertRaw('<div class="view-header">
      No Answers yet.    </div>', 'No Answers yet');
  $this
    ->assertNoRaw('<label for="edit-body-und-0-value">Body </label>', 'No answer body label');
  $this
    ->assertNoFieldByName('title', '', 'No title field exists');
  $this
    ->assertFieldByName("body[{$langcode}][0][value]", '', 'The body field exists');
  $answer = array();
  $answer["body[{$langcode}][0][value]"] = "42 cords of wood.";
  $this
    ->drupalPost('node/1', $answer, 'Save');
  $this
    ->assertRaw('<h2 class="new-answer-form-title">Your Answer</h2>', 'Answers Form exists');
  $this
    ->assertRaw('<div class="view-header">
      1 Answer    </div>', '1 Answer');
  $answer["body[{$langcode}][0][value]"] = "Woodchucks don't chuck wood.";
  $this
    ->drupalPost('node/1', $answer, 'Save');
  $this
    ->assertRaw('<h2 class="new-answer-form-title">Your Answer</h2>', 'Answers Form exists');
  $this
    ->assertRaw('<div class="view-header">
      2 Answers    </div>', '2 Answers');
}