View source
<?php
namespace Drupal\Tests\views_exposed_groups\Functional;
class ViewsExposedGroupsInheritedPropertiesTest extends ViewsExposedGroupsTestBase {
protected function setUp() {
parent::setUp();
$this->defaultView
->getDisplay('default')
->setOption('exposed_form', [
'type' => 'views_exposed_groups',
'options' => [
'views_exposed_groups' => [
'groups' => "Default\nAdvanced",
'format_groups' => 'fieldsets',
'vertical_tabs_summary' => '0',
'group-title' => [
'group' => '0',
'filter_name' => 'title',
'weight' => '-4',
],
'group-nid' => [
'group' => '1',
'filter_name' => 'nid',
'weight' => '-3',
],
'group-uid' => [
'group' => 'no-group',
'filter_name' => 'uid',
'weight' => '0',
],
],
],
]);
$this->defaultView
->save();
}
public function testViewsUi() {
$views_ui_path = '/admin/structure/views/view/' . $this->defaultView->name;
$this
->drupalLogin($this->privilegedUser);
$this
->drupalGet($views_ui_path . '/edit');
$this
->clickExposedFormOptionsLink('Grouped form');
$edit = [
'exposed_form_options[reset_button]' => '1',
'exposed_form_options[autosubmit]' => '1',
'exposed_form_options[autosubmit_hide]' => '1',
];
$this
->drupalPostForm(NULL, $edit, 'Apply');
$exposed_options_path = 'admin/structure/views/nojs/display/' . $this->defaultView->name . '/default/exposed_form_options';
$this
->drupalGet($exposed_options_path);
$this
->assertFieldByName('exposed_form_options[reset_button]', '1');
$this
->assertFieldByName('exposed_form_options[autosubmit]', '1');
$this
->assertFieldByName('exposed_form_options[autosubmit_hide]', '1');
}
public function testView() {
$view_path = $this->defaultView
->getDisplay('page_1')
->getOption('path');
$this->defaultView
->getDisplay('default')
->setOption('exposed_form.options.autosubmit', TRUE)
->setOption('exposed_form.options.autosubmit_hide', TRUE)
->setOption('exposed_form.options.reset_button', TRUE);
$this->defaultView
->save();
$this
->drupalLogin($this->unprivilegedUser);
$this
->drupalGet($view_path);
$this
->assertFieldByXpath('//input[@value="Apply" and @type="submit" and contains(@class, "js-hide")]');
$this
->assertFieldByXpath('//input[@value="Reset" and @type="submit"]');
}
}