Commit c1f84e63 authored by webchick's avatar webchick
Browse files

Issue #1820332 by dawehner, tim.plunkett, msonnabaum: Fixed Views preview uses...

Issue #1820332 by dawehner, tim.plunkett, msonnabaum: Fixed Views preview uses the wrong query class name.
parent 0d1d57fb
......@@ -91,6 +91,29 @@ function testEditUI() {
views_invalidate_cache();
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->assertNoFieldById('edit-displays-top-add-display-embed');
// Configure to hide/show the sql at the preview.
$edit = array(
'ui_show_sql_query_enabled' => FALSE,
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost(NULL, array(), t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]/pre');
$this->assertEqual(count($xpath), 0, 'The views sql is hidden.');
$edit = array(
'ui_show_sql_query_enabled' => TRUE,
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost(NULL, array(), t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
$this->assertEqual(count($xpath), 1, 'The views sql is shown.');
$this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
$this->assertTrue(strpos($xpath[0], "node.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
}
}
......@@ -8,6 +8,8 @@
namespace Drupal\views_ui;
use Drupal\views\ViewExecutable;
use Drupal\Core\Database\Database;
use Drupal\views\Plugin\views\query\Sql;
/**
* Stores UI related temporary settings.
......@@ -1791,7 +1793,7 @@ public function renderPreview($display_id, $args = array()) {
// Only the sql default class has a method getArguments.
$quoted = array();
if (get_class($this->query) == 'views_plugin_query_default') {
if ($this->query instanceof Sql) {
$quoted = $query->getArguments();
$connection = Database::getConnection();
foreach ($quoted as $key => $val) {
......
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