3 namespace Drupal\Tests\views_ui\Functional;
6 * Tests the boolean filter UI.
9 * @see \Drupal\views\Plugin\views\filter\BooleanOperator
11 class FilterBooleanWebTest extends UITestBase {
14 * Views used by this test.
18 public static $testViews = ['test_view'];
21 * Tests the filter boolean UI.
23 public function testFilterBooleanUI() {
24 $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.status]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
26 // Check the field widget label. 'title' should be used as a fallback.
27 $result = $this->cssSelect('#edit-options-value--wrapper legend span');
28 $this->assertEqual($result[0]->getHtml(), 'Status');
30 $this->drupalPostForm(NULL, [], t('Expose filter'));
31 $this->drupalPostForm(NULL, [], t('Grouped filters'));
34 $edit['options[group_info][group_items][1][title]'] = 'Published';
35 $edit['options[group_info][group_items][1][operator]'] = '=';
36 $edit['options[group_info][group_items][1][value]'] = 1;
37 $edit['options[group_info][group_items][2][title]'] = 'Not published';
38 $edit['options[group_info][group_items][2][operator]'] = '=';
39 $edit['options[group_info][group_items][2][value]'] = 0;
40 $edit['options[group_info][group_items][3][title]'] = 'Not published2';
41 $edit['options[group_info][group_items][3][operator]'] = '!=';
42 $edit['options[group_info][group_items][3][value]'] = 1;
44 $this->drupalPostForm(NULL, $edit, t('Apply'));
46 $this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status');
48 $result = $this->xpath('//input[@name="options[group_info][group_items][1][value]"]');
49 $this->assertEqual($result[1]->getAttribute('checked'), 'checked');
50 $result = $this->xpath('//input[@name="options[group_info][group_items][2][value]"]');
51 $this->assertEqual($result[2]->getAttribute('checked'), 'checked');
52 $result = $this->xpath('//input[@name="options[group_info][group_items][3][value]"]');
53 $this->assertEqual($result[1]->getAttribute('checked'), 'checked');
55 // Test that there is a remove link for each group.
56 $this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
58 // Test selecting a default and removing an item.
60 $edit['options[group_info][default_group]'] = 2;
61 $edit['options[group_info][group_items][3][remove]'] = 1;
62 $this->drupalPostForm(NULL, $edit, t('Apply'));
63 $this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status');
64 $this->assertFieldByName('options[group_info][default_group]', 2, 'Second item was set as the default.');
65 $this->assertNoField('options[group_info][group_items][3][remove]', 'Third item was removed.');