diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php index c7fc24bc175a..191e4b459c2f 100644 --- a/core/modules/views_ui/src/Tests/PreviewTest.php +++ b/core/modules/views_ui/src/Tests/PreviewTest.php @@ -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. * diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 260a71e84380..31af29691b40 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -707,7 +707,7 @@ class ViewUI implements ViewStorageInterface { $rows['statistics'][] = array('' . t('View render time') . '', 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 000000000000..93ba44e64bf3 --- /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 000000000000..f68c40bdb2c4 --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test/views_ui_test.module @@ -0,0 +1,17 @@ +result), + ); +}