public function DefaultViewRecentComments::testPageDisplay

Tests the page defined by the comments_recent view.

File

drupal/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php, line 136
Contains \Drupal\comment\Tests\Views\DefaultViewRecentComments.

Class

DefaultViewRecentComments

Namespace

Drupal\comment\Tests\Views

Code

public function testPageDisplay() {
  $view = views_get_view('comments_recent');
  $view
    ->setDisplay('page_1');
  $this
    ->executeView($view);
  $map = array(
    'comment_nid' => 'nid',
    'comment_subject' => 'subject',
    'comment_changed' => 'changed',
    'comment_changed' => 'created',
    'cid' => 'cid',
  );
  $expected_result = array();
  foreach (array_values($this->commentsCreated) as $key => $comment) {
    $expected_result[$key]['nid'] = $comment->nid->target_id;
    $expected_result[$key]['subject'] = $comment->subject->value;
    $expected_result[$key]['changed'] = $comment->changed->value;
    $expected_result[$key]['created'] = $comment->created->value;
    $expected_result[$key]['cid'] = $comment
      ->id();
  }
  $this
    ->assertIdenticalResultset($view, $expected_result, $map);

  // Check the number of results given by the display is the expected.
  $this
    ->assertEqual(count($view->result), $this->pageDisplayResults, format_string('There are exactly @results comments. Expected @expected', array(
    '@results' => count($view->result),
    '@expected' => $this->pageDisplayResults,
  )));
}