diff --git a/core/modules/views/src/Tests/Handler/HandlerTest.php b/core/modules/views/src/Tests/Handler/HandlerTest.php index 4904baf..f084f90 100644 --- a/core/modules/views/src/Tests/Handler/HandlerTest.php +++ b/core/modules/views/src/Tests/Handler/HandlerTest.php @@ -69,26 +69,6 @@ protected function viewsData() { } /** - * @todo - * This should probably moved to a filter related test. - */ - function testFilterInOperatorUi() { - $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); - $this->drupalLogin($admin_user); - - $path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type'; - $this->drupalGet($path); - $this->assertFieldByName('options[expose][reduce]', FALSE); - - $edit = array( - 'options[expose][reduce]' => TRUE, - ); - $this->drupalPostForm($path, $edit, t('Apply')); - $this->drupalGet($path); - $this->assertFieldByName('options[expose][reduce]', TRUE); - } - - /** * Tests the breakString method. */ public function testBreakString() { diff --git a/core/modules/views_ui/src/Tests/FilterUITest.php b/core/modules/views_ui/src/Tests/FilterUITest.php new file mode 100644 index 0000000..f90900d --- /dev/null +++ b/core/modules/views_ui/src/Tests/FilterUITest.php @@ -0,0 +1,90 @@ +drupalCreateContentType(['type' => 'page']); + $this->enableViewsTestModule(); + } + + /** + * Tests that "Limit list to selected items" option is saved as expected when + * editing the Content type filter from the UI. + */ + public function testFilterInOperatorUi() { + $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); + $this->drupalLogin($admin_user); + + $path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type'; + $this->drupalGet($path); + $this->assertFieldByName('options[expose][reduce]', FALSE); + + $edit = [ + 'options[expose][reduce]' => TRUE + ]; + $this->drupalPostForm($path, $edit, t('Apply')); + $this->drupalGet($path); + $this->assertFieldByName('options[expose][reduce]', TRUE); + } + + /** + * Tests the filters from the UI. + */ + public function testFiltersUI() { + $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']); + $this->drupalLogin($admin_user); + + // Tests that we can create a new filter group from UI. + $this->drupalGet('admin/structure/views/nojs/rearrange-filter/test_filter_groups/page'); + $this->assertNoRaw('Group 3', 'Group 3 has not been added yet.'); + + // Create 2 new groups. + $this->drupalPostForm(NULL, [], t('Create new filter group')); + $this->drupalPostForm(NULL, [], t('Create new filter group')); + + // Remove the new group 3. + $this->drupalPostForm(NULL, [], t('Remove group 3')); + + // Verify that the group 4 is now named as 3. + $this->assertRaw('Group 3', 'Group 3 still exists.'); + + // Remove the group 3 again. + $this->drupalPostForm(NULL, [], t('Remove group 3')); + + // Group 3 now does not exist. + $this->assertNoRaw('Group 3', 'Group 3 has not been added yet.'); + } + +}