function QueryTest::testQueryUI

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest::testQueryUI()
  2. 10 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest::testQueryUI()
  3. 11.x core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest::testQueryUI()

Tests query plugins settings.

File

core/modules/views_ui/tests/src/Functional/QueryTest.php, line 40

Class

QueryTest
Tests query plugins.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testQueryUI() {
    $view = View::load('test_view');
    $display =& $view->getDisplay('default');
    $display['display_options']['query'] = [
        'type' => 'query_test',
    ];
    $view->save();
    // Save some query settings.
    $query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
    $random_value = $this->randomMachineName();
    $this->drupalPostForm($query_settings_path, [
        'query[options][test_setting]' => $random_value,
    ], t('Apply'));
    $this->drupalPostForm(NULL, [], t('Save'));
    // Check that the settings are saved into the view itself.
    $view = Views::getView('test_view');
    $view->initDisplay();
    $view->initQuery();
    $this->assertEqual($random_value, $view->query->options['test_setting'], 'Query settings got saved');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.