diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
index ff783ef..81341fd 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
@@ -7,8 +7,6 @@
namespace Drupal\views_ui\Tests;
-use Drupal\views_ui\ViewUI;
-
/**
* Tests the preview form in the UI.
*/
@@ -92,17 +90,23 @@ public function testPreviewWithPagersUI() {
}
// Test Full Pager.
- $view = entity_load('view', 'test_pager_full');
- $view_ui = new ViewUI($view);
- $rendered_preview = $view_ui->renderPreview('default');
- $result = simplexml_load_string('' . $rendered_preview . '');
+ $this->drupalGet('admin/structure/views/view/test_pager_full/preview/default');
+ $result = $this->drupalPostAJAX(NULL, array(), array('op' => t('Update preview')));
+
+ // Has AJAX callback replied with an insert command? If so, we can
+ // assume that the page content was updated with AJAX returned data.
+ $result_commands = array();
+ foreach ($result as $command) {
+ $result_commands[$command['command']] = $command;
+ }
+ $this->assertTrue(isset($result_commands['insert']), 'AJAX insert command received.');
// Are there 5 rows returned?
- $elements = $result->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
+ $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
$this->assertEqual(count($elements), 5, '5 items found on page.');
// Test that the pager is present and rendered.
- $elements = $result->xpath('//ul[@class = "pager"]/li');
+ $elements = $this->xpath('//ul[@class = "pager"]/li');
$this->assertTrue(!empty($elements), 'Full pager found.');
// Verify elements and links to pages.
@@ -137,17 +141,23 @@ public function testPreviewWithPagersUI() {
}
// Test Mini Pager.
- $view = entity_load('view', 'test_mini_pager');
- $view_ui = new ViewUI($view);
- $rendered_preview = $view_ui->renderPreview('default');
- $result = simplexml_load_string('' . $rendered_preview . '');
+ $this->drupalGet('admin/structure/views/view/test_mini_pager/preview/default');
+ $result = $this->drupalPostAJAX(NULL, array(), array('op' => t('Update preview')));
+
+ // Has AJAX callback replied with an insert command? If so, we can
+ // assume that the page content was updated with AJAX returned data.
+ $result_commands = array();
+ foreach ($result as $command) {
+ $result_commands[$command['command']] = $command;
+ }
+ $this->assertTrue(isset($result_commands['insert']), 'AJAX insert command received.');
// Are there 3 rows returned?
- $elements = $result->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
+ $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
$this->assertEqual(count($elements), 3, '3 items found on page.');
// Test that the pager is present and rendered.
- $elements = $result->xpath('//ul[@class = "pager"]/li');
+ $elements = $this->xpath('//ul[@class = "pager"]/li');
$this->assertTrue(!empty($elements), 'Mini pager found.');
// Verify elements and links to pages.