public function DefaultViewRecentComments::testPageDisplay

Tests the page defined by the comments_recent view.

File

drupal/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php, line 129
Definition of Drupal\views\Tests\Comment\DefaultViewRecentComments.

Class

DefaultViewRecentComments

Namespace

Drupal\views\Tests\Comment

Code

public function testPageDisplay() {
  $view = views_get_view('comments_recent');
  $view
    ->setDisplay('page');
  $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;
    $expected_result[$key]['subject'] = $comment->subject;
    $expected_result[$key]['changed'] = $comment->changed;
    $expected_result[$key]['created'] = $comment->created;
    $expected_result[$key]['cid'] = $comment->cid;
  }
  $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,
  )));
}