Commit 1f0a6298 authored by catch's avatar catch

Issue #2651328 by aerozeppelin, GeduR: Views Handler Filter InOperator exposed...

Issue #2651328 by aerozeppelin, GeduR: Views Handler Filter InOperator exposed fires illegal choice when all option has been selected
parent 08febd9a
......@@ -206,7 +206,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
}
if (empty($this->options['expose']['multiple'])) {
if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce'])) || isset($this->options['value']['all'])) {
$default_value = 'All';
}
elseif (empty($default_value)) {
......
......@@ -18,19 +18,24 @@ class FilterTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_filter');
public static $testViews = array('test_filter', 'test_filter_in_operator_ui');
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('views_ui');
public static $modules = array('views_ui', 'node');
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
$this->adminUser = $this->drupalCreateUser(array('administer views'));
$this->drupalLogin($this->adminUser);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
}
/**
......@@ -138,4 +143,23 @@ public function testFilterQuery() {
$this->assertEqual(count($view->result), 5, format_string('All @count results returned', array('@count' => count($view->displayHandlers))));
}
/**
* Test no error message is displayed when all options are selected in an
* exposed filter.
*/
public function testInOperatorSelectAllOptions() {
$view = Views::getView('test_filter_in_operator_ui');
$row['row[type]'] = 'fields';
$this->drupalPostForm('admin/structure/views/nojs/display/test_filter_in_operator_ui/default/row', $row, t('Apply'));
$field['name[node_field_data.nid]'] = TRUE;
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_filter_in_operator_ui/default/field', $field, t('Add and configure fields'));
$this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/field/nid', [], t('Apply'));
$edit['options[value][all]'] = TRUE;
$edit['options[value][article]'] = TRUE;
$edit['options[value][page]'] = TRUE;
$this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type', $edit, t('Apply'));
$this->drupalPostForm('admin/structure/views/view/test_filter_in_operator_ui/edit/default', [], t('Save'));
$this->drupalPostForm(NULL, [], t('Update preview'));
$this->assertNoText('An illegal choice has been detected.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment