QueryOptionsTest.php in Drupal 10
File
core/modules/views/tests/src/Functional/Plugin/QueryOptionsTest.php
View source
<?php
namespace Drupal\Tests\views\Functional\Plugin;
use Drupal\Tests\views\Functional\ViewTestBase;
class QueryOptionsTest extends ViewTestBase {
public static $testViews = [
'test_view',
];
protected static $modules = [
'node',
'views_ui',
];
protected $defaultTheme = 'stark';
public function testStoreQuerySettingsOverride() {
\Drupal::configFactory()
->getEditable('views.settings')
->set('ui.show.default_display', TRUE)
->save();
$admin_user = $this
->drupalCreateUser([
'administer views',
'administer site configuration',
]);
$this
->drupalLogin($admin_user);
$edit = [];
$this
->drupalGet('admin/structure/views/view/test_view/edit');
$this
->submitForm($edit, 'Add Page');
$this
->drupalGet('admin/structure/views/nojs/display/test_view/page_1/query');
$this
->assertSession()
->checkboxNotChecked('query[options][distinct]');
$edit = [
'override[dropdown]' => 'page_1',
'query[options][distinct]' => 1,
];
$this
->submitForm($edit, 'Apply');
$this
->drupalGet('admin/structure/views/nojs/display/test_view/page_1/query');
$this
->assertSession()
->checkboxChecked('query[options][distinct]');
$edit = [
'query[options][query_comment]' => 'comment',
'query[options][query_tags]' => 'query_tag, another_tag',
];
$this
->submitForm($edit, 'Apply');
$this
->drupalGet('admin/structure/views/nojs/display/test_view/page_1/query');
$this
->assertSession()
->checkboxChecked('query[options][distinct]');
$this
->assertSession()
->fieldValueEquals('query[options][query_comment]', 'comment');
$this
->assertSession()
->fieldValueEquals('query[options][query_tags]', 'query_tag, another_tag');
}
}