public function AnswersTestCase::testLabels in Answers 7.3
Same name and namespace in other branches
- 7.4 answers.test \AnswersTestCase::testLabels()
Check node labels.
File
- ./
answers.test, line 48 - 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/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">Question <span class="form-required" title="This field is required.">*</span></label>', 'The question title is Question');
$this
->assertRaw('<label for="edit-body-und-0-value">Description ', 'The question body is Decription');
$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/question', $question, 'Ask Your Question');
$this
->assertRaw('<div class="view-empty">
<p><em>No answers yet</em></p>
</div>', 'No Answers yet');
$this
->assertLink('Post an Answer', 0, 'Answers Form link exists');
$this
->clickLink('Post an Answer');
$this
->assertNoRaw('<label for="edit-body-und-0-value">Body </label>', 'No answer body label');
$this
->assertNoFieldByName('title', 'Answer', 'Title field is Answer');
$this
->assertFieldByName("body[{$langcode}][0][value]", '', 'The body field exists');
$answer = array();
$answer['title'] = 'The Answer!';
$answer["body[{$langcode}][0][value]"] = "42 cords of wood.";
$this
->drupalPost('node/add/answer/1', $answer, 'Post Your Answer', array(
'query' => array(
'destination' => 'node/1',
),
));
$this
->assertRaw('<h2>The Answer!</h2>', '1st Answer exists');
$this
->assertLink('Post an Answer', 0, 'Answers Form link exists');
$this
->clickLink('Post an Answer');
$answer['title'] = 'Another Answer!';
$answer["body[{$langcode}][0][value]"] = "Woodchucks don't chuck wood.";
$this
->drupalPost('node/add/answer/1', $answer, 'Post Your Answer', array(
'query' => array(
'destination' => 'node/1',
),
));
$this
->assertLink('Post an Answer', 0, 'Answers Form link exists');
$this
->assertRaw('<h2>The Answer!</h2>', '1st Answer exists');
$this
->assertRaw('<h2>Another Answer!</h2>', '2st Answer exists');
}