diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php index c7fc24bc175af151a38a9eeaec2d7b53086490d7..191e4b459c2f70d4b4aeea35769e357f0a3b096a 100644 --- a/core/modules/views_ui/src/Tests/PreviewTest.php +++ b/core/modules/views_ui/src/Tests/PreviewTest.php @@ -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. * diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 260a71e843805f1d639ea71bb176e2685bc1f44d..31af29691b402818c6f9c4c0bed27659c6fd8709 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -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 diff --git a/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.info.yml b/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..93ba44e64bf3672e000acc037ffcc93b284ecf26 --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.info.yml @@ -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 diff --git a/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.module b/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.module new file mode 100644 index 0000000000000000000000000000000000000000..f68c40bdb2c4d4b4e718f03e62c54ad7984679e0 --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.module @@ -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), + ); +}