You are here

class QueryTest in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest
  2. 10 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  3. 10 core/modules/views/tests/src/Kernel/Plugin/QueryTest.php \Drupal\Tests\views\Kernel\Plugin\QueryTest
  4. 10 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest
  5. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest
Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  2. 9 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest

Tests query plugins.

@group views_ui

Hierarchy

Expanded class hierarchy of QueryTest

1 string reference to 'QueryTest'
QueryTest::calculateDependencies in core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php

File

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

Namespace

Drupal\Tests\views_ui\Functional
View source
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
      ->drupalGet($query_settings_path);
    $this
      ->submitForm([
      'query[options][test_setting]' => $random_value,
    ], 'Apply');
    $this
      ->submitForm([], 'Save');

    // Check that the settings are saved into the view itself.
    $view = Views::getView('test_view');
    $view
      ->initDisplay();
    $view
      ->initQuery();
    $this
      ->assertEquals($random_value, $view->query->options['test_setting'], 'Query settings got saved');
  }

}

Members