Issue #1820332 by dawehner, tim.plunkett, msonnabaum: Fixed Views preview uses the wrong query class name.

8.0.x
webchick 2012-10-29 19:52:28 -07:00
parent 0d1d57fbf0
commit c1f84e6355
2 changed files with 26 additions and 1 deletions

View File

@ -91,6 +91,29 @@ class SettingsTest extends UITestBase {
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.');
}
}

View File

@ -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 @@ class ViewUI extends ViewExecutable {
// 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) {