Same name in this branch
  1. 10 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  2. 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\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
Same name and namespace in other branches
  1. 8.9.x 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

File

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

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

Namesort descending Modifiers Type Description Overrides
QueryTest::$defaultTheme protected property
QueryTest::$testViews public static property Views used by this test.
QueryTest::testQueryUI public function Tests query plugins settings.
QueryTest::viewsData protected function Returns the views data definition. Overrides ViewTestBase::viewsData
UITestBase::$adminUser protected property An admin user with the 'administer views' permission. 5
UITestBase::$fullAdminUser protected property An admin user with administrative permissions for views, blocks, and nodes.
UITestBase::$modules protected static property Modules to enable. Overrides ViewTestBase::$modules 23
UITestBase::drupalGet protected function
UITestBase::randomView public function A helper method which creates a random view.
UITestBase::setUp protected function Sets up the test. Overrides ViewTestBase::setUp 15
ViewResultAssertionTrait::assertIdenticalResultset protected function Verifies that a result set returned by a View matches expected values.
ViewResultAssertionTrait::assertIdenticalResultsetHelper protected function Performs View result assertions.
ViewResultAssertionTrait::assertNotIdenticalResultset protected function Verifies that a result set returned by a View differs from certain values.
ViewTestBase::dataSet protected function Returns a very simple test dataset. 1
ViewTestBase::enableViewsTestModule protected function Sets up the views_test_data.module.
ViewTestBase::executeView protected function Executes a view.
ViewTestBase::helperButtonHasLabel protected function Asserts the existence of a button with a certain ID and label.
ViewTestBase::orderResultSet protected function Orders a nested array containing a result set based on a given column.
ViewTestBase::schemaDefinition protected function Returns the schema definition. 1