public function DefaultViewRecentComments::testBlockDisplay

Tests the block defined by the comments_recent view.

File

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

Class

DefaultViewRecentComments

Namespace

Drupal\views\Tests\Comment

Code

public function testBlockDisplay() {
  $view = views_get_view('comments_recent');
  $view
    ->setDisplay('block');
  $this
    ->executeView($view);
  $map = array(
    'comment_nid' => 'nid',
    'comment_subject' => 'subject',
    'cid' => 'cid',
    'comment_changed' => 'changed',
  );
  $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]['cid'] = $comment->cid;
    $expected_result[$key]['changed'] = $comment->changed;
  }
  $this
    ->assertIdenticalResultset($view, $expected_result, $map);

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