Commit 062ca316 authored by alexpott's avatar alexpott

Issue #2293899 by leon.nk, nlisgo: Fixed hook_views_preview_info passes an...

Issue #2293899 by leon.nk, nlisgo: Fixed hook_views_preview_info passes an instance of ViewsUI instead of ViewExecutable.
parent e83b1202
......@@ -201,6 +201,24 @@ public function testPreviewWithPagersUI() {
$this->assertTrue($elements[2]->a, "Link to next page found.");
}
/**
* Tests the additional information query info area.
*/
public function testPreviewAdditionalInfo() {
\Drupal::moduleHandler()->install(array('views_ui_test'));
$this->resetAll();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertResponse(200);
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
// Check for implementation of hook_views_preview_info_alter().
// @see views_ui_test.module
$elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(':text' => t('Test row count')));
$this->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.');
}
/**
* Get the preview form and force an AJAX preview update.
*
......
......@@ -707,7 +707,7 @@ public function renderPreview($display_id, $args = array()) {
$rows['statistics'][] = array('<strong>' . t('View render time') . '</strong>', t('@time ms', array('@time' => intval($this->executable->render_time * 100000) / 100)));
}
\Drupal::moduleHandler()->alter('views_preview_info', $rows, $this);
\Drupal::moduleHandler()->alter('views_preview_info', $rows, $this->executable);
}
else {
// No query was run. Display that information in place of either the
......
name: 'Views UI Test'
type: module
description: 'Test module for Views UI.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- views_ui
<?php
/**
* @file
* Helper module for Views UI tests.
*/
/**
* Implements hook_views_preview_info_alter().
*
* Add a row count row to the live preview area.
*/
function views_ui_test_views_preview_info_alter(&$rows, $view) {
$rows['query'][] = array(
t('Test row count'), count($view->result),
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment