You are here

public function AnswersTestCase::testAnswersOrphanReport in Answers 7.4

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

Tests the Orphaned answers report.

File

./answers.test, line 199
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',
    'administer content types',
  ));
  $this
    ->drupalLogin($user);
  $settings = array(
    'type' => 'answers_question',
    'nid' => NULL,
  );
  $question = $this
    ->drupalCreateNode($settings);
  $settings['type'] = 'answers_answer';
  $settings['answers_related_question'][LANGUAGE_NONE][0]['target_id'] = $question->nid;
  $answer_1 = $this
    ->drupalCreateNode($settings);
  $answer_2 = $this
    ->drupalCreateNode($settings);
  db_delete('node')
    ->condition('nid', $question->nid)
    ->execute();
  db_delete('field_data_answers_related_question')
    ->condition('entity_id', $answer_1->nid)
    ->condition('bundle', 'answers_answer')
    ->condition('answers_related_question_target_id', $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');
}