diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 726381f4b360f27b06536d86cfb2a5854eaaf1a2..46e79e1f415c2d39d7bc652897e2570d50ac4b2a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -2212,7 +2212,7 @@ public function submitOptionsForm(&$form, &$form_state) { } break; case 'query': - $plugin = $this->get_plugin('query'); + $plugin = $this->getPlugin('query'); if ($plugin) { $plugin->submitOptionsForm($form['query']['options'], $form_state); $this->setOption('query', $form_state['values'][$section]); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php index 991d38e7dd96692b3a0d736dad568c9bb158b7c7..43e52cade84f007f85d700c5e903c0e9919e2810 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php @@ -246,7 +246,6 @@ public function buildOptionsForm(&$form, &$form_state) { '#default_value' => implode(', ', $this->options['query_tags']), '#element_validate' => array('views_element_validate_tags'), ); - $form_state['build_info']['files']['foo'] = drupal_get_path('module', 'views') . '/lib/Drupal/views/Plugin/Query/SqlQuery.php'; } /** diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..83f0bfa231808b056d93a9c83cb524656de5a796 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php @@ -0,0 +1,53 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Tests\UI\QueryTest. + */ + +namespace Drupal\views\Tests\UI; + +use Drupal\views\Tests\ViewTestBase; +use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin; + +/** + * Tests query plugins. + */ +class QueryTest extends UITestBase { + + public static function getInfo() { + return array( + 'name' => 'Query: UI', + 'description' => 'Tests query plugins UI.', + 'group' => 'Views UI' + ); + } + + /** + * Overrides \Drupal\views\Tests\ViewTestBase::viewsData(). + */ + protected function viewsData() { + $data = parent::viewsData(); + $data['views_test_data']['table']['base']['query_id'] = 'query_test'; + + return $data; + } + + /** + * Tests query plugins settings. + */ + public function testQueryUI() { + // Save some query settings. + $query_settings_path = "admin/structure/views/nojs/display/test_view/default/query"; + $random_value = $this->randomName(); + $this->drupalPost($query_settings_path, array('query[options][test_setting]' => $random_value), t('Apply')); + $this->drupalPost(NULL, array(), t('Save')); + + // Check that the settings are saved into the view itself. + $view = views_get_view('test_view'); + $view->initDisplay(); + $view->initQuery(); + $this->assertEqual($random_value, $view->query->options['test_setting'], 'Query settings got saved'); + } + +} diff --git a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php index eab54df0fca2734c8354b5b1b0013be8f269bf19..4ee2a487f1fa2da98e4a02ac60f9f30706519e07 100644 --- a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php +++ b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php @@ -27,6 +27,29 @@ class QueryTest extends QueryPluginBase { protected $allItems = array(); protected $orderBy = array(); + /** + * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::defineOptions(). + */ + protected function defineOptions() { + $options = parent::defineOptions(); + $options['test_setting'] = array('default' => ''); + + return $options; + } + + /** + * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::buildOptionsForm(). + */ + public function buildOptionsForm(&$form, &$form_state) { + parent::buildOptionsForm($form, $form_state); + + $form['test_setting'] = array( + '#title' => t('Test setting'), + '#type' => 'textfield', + '#default_value' => $this->options['test_setting'], + ); + } + /** * Sets the allItems property. *