QueryTest.php

Same filename in this branch
  1. 8.9.x core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
  2. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
  3. 8.9.x core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
  4. 8.9.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
Same filename in other branches
  1. 9 core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
  2. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
  3. 9 core/modules/views_ui/tests/src/Functional/QueryTest.php
  4. 9 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
  5. 9 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
  6. 10 core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
  7. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
  8. 10 core/modules/views_ui/tests/src/Functional/QueryTest.php
  9. 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
  10. 10 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
  11. 11.x core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
  12. 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
  13. 11.x core/modules/views_ui/tests/src/Functional/QueryTest.php
  14. 11.x core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
  15. 11.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php

Namespace

Drupal\Tests\views_ui\Functional

File

core/modules/views_ui/tests/src/Functional/QueryTest.php

View source
<?php

namespace Drupal\Tests\views_ui\Functional;

use Drupal\views\Views;
use Drupal\views\Entity\View;

/**
 * Tests query plugins.
 *
 * @group views_ui
 */
class QueryTest extends UITestBase {
    
    /**
     * Views used by this test.
     *
     * @var array
     */
    public static $testViews = [
        'test_view',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * {@inheritdoc}
     */
    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() {
        $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');
    }

}

Classes

Title Deprecated Summary
QueryTest Tests query plugins.

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