Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / src / Tests / FilterBooleanWebTest.php
1 <?php
2
3 namespace Drupal\views_ui\Tests;
4
5 /**
6  * Tests the boolean filter UI.
7  *
8  * @group views_ui
9  * @see \Drupal\views\Plugin\views\filter\BooleanOperator
10  */
11 class FilterBooleanWebTest extends UITestBase {
12
13   /**
14    * Views used by this test.
15    *
16    * @var array
17    */
18   public static $testViews = ['test_view'];
19
20   /**
21    * Tests the filter boolean UI.
22    */
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')]));
25
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((string) $result[0], 'Status');
29
30     $this->drupalPostForm(NULL, [], t('Expose filter'));
31     $this->drupalPostForm(NULL, [], t('Grouped filters'));
32
33     $edit = [];
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;
43
44     $this->drupalPostForm(NULL, $edit, t('Apply'));
45
46     $this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status');
47
48     $result = $this->xpath('//input[@name="options[group_info][group_items][1][value]"]');
49     $this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
50     $result = $this->xpath('//input[@name="options[group_info][group_items][2][value]"]');
51     $this->assertEqual((int) $result[2]->attributes()->checked, 'checked');
52     $result = $this->xpath('//input[@name="options[group_info][group_items][3][value]"]');
53     $this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
54
55     // Test that there is a remove link for each group.
56     $this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
57
58     // Test selecting a default and removing an item.
59     $edit = [];
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.');
66   }
67
68 }