Issue #2293899 by leon.nk, nlisgo: Fixed hook_views_preview_info passes an instance of ViewsUI instead of ViewExecutable.
parent
e83b1202a3
commit
062ca316d7
|
@ -201,6 +201,24 @@ class PreviewTest extends UITestBase {
|
|||
$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 @@ class ViewUI implements ViewStorageInterface {
|
|||
$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
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
name: 'Views UI Test'
|
||||
type: module
|
||||
description: 'Test module for Views UI.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
|
@ -0,0 +1,17 @@
|
|||
<?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),
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue