You are here

protected function PreviewTest::clickPreviewLinkAJAX in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/PreviewTest.php \Drupal\views_ui\Tests\PreviewTest::clickPreviewLinkAJAX()

Mimic clicking on a preview link.

Parameters

string $url: The url to navigate to.

int $row_count: The expected number of rows in the preview.

1 call to PreviewTest::clickPreviewLinkAJAX()
PreviewTest::testPreviewWithPagersUI in core/modules/views_ui/src/Tests/PreviewTest.php
Tests pagers in the preview form.

File

core/modules/views_ui/src/Tests/PreviewTest.php, line 257
Contains \Drupal\views_ui\Tests\PreviewTest.

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\views_ui\Tests

Code

protected function clickPreviewLinkAJAX($url, $row_count) {
  $content = $this->content;
  $drupal_settings = $this->drupalSettings;
  $ajax_settings = array(
    'wrapper' => 'views-preview-wrapper',
    'method' => 'replaceWith',
  );
  $url = $this
    ->getAbsoluteUrl($url);
  $post = array(
    'js' => 'true',
  ) + $this
    ->getAjaxPageStatePostData();
  $result = Json::decode($this
    ->drupalPost($url, 'application/vnd.drupal-ajax', $post));
  if (!empty($result)) {
    $this
      ->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings);
  }
  $this
    ->assertPreviewAJAX($result, $row_count);
}