You are here

public function AnswersTestCase::testAnswersOrphanReport in Answers 7.3

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

Tests the Orphaned answers report.

File

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

Class

AnswersTestCase
Tests the functionality of the answers module.

Code

public function testAnswersOrphanReport() {
  $user = $this
    ->drupalCreateUser(array(
    'access site reports',
    'administer site configuration',
  ));
  $this
    ->drupalLogin($user);
  $settings = array(
    'type' => 'question',
    'nid' => NULL,
  );
  $question = $this
    ->drupalCreateNode($settings);
  $settings['type'] = 'answer';
  $settings['field_answer_question'][LANGUAGE_NONE][0]['nid'] = $question->nid;
  $answer_1 = $this
    ->drupalCreateNode($settings);
  $answer_2 = $this
    ->drupalCreateNode($settings);
  db_delete('node')
    ->condition('nid', $question->nid)
    ->execute();
  db_delete('field_data_field_answer_question')
    ->condition('entity_id', $answer_1->nid)
    ->condition('bundle', 'answer')
    ->condition('field_answer_question_nid', $question->nid)
    ->execute();
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertLink('Orphaned', 0, 'Orphaned answers report link is present.');
  $this
    ->clickLink('Orphaned');
  $this
    ->assertLinkByHref('node/2/edit', 0, 'A link to orphan 1 appears on the page');
  $this
    ->assertLinkByHref('node/3/edit', 0, 'A link to orphan 2 appears on the page');
}