function CToolsViewsBasicViewBlockTest::testDisableFilters

Same name in other branches
  1. 4.0.x modules/ctools_views/tests/src/Functional/CToolsViewsBasicViewBlockTest.php \Drupal\Tests\ctools_views\Functional\CToolsViewsBasicViewBlockTest::testDisableFilters()

Test ctools_views 'disable_filters' configuration.

File

modules/ctools_views/tests/src/Functional/CToolsViewsBasicViewBlockTest.php, line 337

Class

CToolsViewsBasicViewBlockTest
Tests ctools_views block display plugin overrides settings from a basic View.

Namespace

Drupal\Tests\ctools_views\Functional

Code

public function testDisableFilters() {
    $default_theme = $this->config('system.theme')
        ->get('default');
    // Get the "Configure block" form for our Views block.
    $this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_filter/' . $default_theme);
    $this->assertSession()
        ->fieldExists('edit-settings-override-filters-status-disable');
    $this->assertSession()
        ->fieldExists('edit-settings-override-filters-job-disable');
    // Add block to sidebar_first region with default settings.
    $edit = [];
    $edit['region'] = 'sidebar_first';
    $edit['id'] = 'views_block__ctools_views_test_view_block_filter';
    $edit['settings[exposed][filter-status][exposed]'] = 1;
    $edit['settings[exposed][filter-job][exposed]'] = 1;
    $this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_filter/' . $default_theme);
    $this->submitForm($edit, 'Save block');
    // Assert disable_filters default settings.
    $this->drupalGet('<front>');
    // Check that the default settings show both filters.
    $this->assertSession()
        ->fieldExists('status');
    $this->assertSession()
        ->fieldExists('job');
    // Override disable_filters settings.
    $edit = [];
    $edit['region'] = 'sidebar_first';
    $edit['settings[exposed][filter-status][exposed]'] = 1;
    $edit['settings[exposed][filter-job][exposed]'] = 1;
    $edit['settings[override][filters][status][disable]'] = 1;
    $edit['settings[override][filters][job][disable]'] = 1;
    $this->drupalGet('admin/structure/block/manage/views_block__ctools_views_test_view_block_filter');
    $this->submitForm($edit, 'Save block');
    $block = $this->storage
        ->load('views_block__ctools_views_test_view_block_filter');
    $config = $block->getPlugin()
        ->getConfiguration();
    $this->assertEquals(1, $config['filter']['status']['disable'], "'disable_filters' setting is properly saved.");
    $this->assertEquals(1, $config['filter']['job']['disable'], "'disable_filters' setting is properly saved.");
    // Assert disable_filters overridden settings.
    $this->drupalGet('<front>');
    $this->assertSession()
        ->fieldNotExists('status');
    $this->assertSession()
        ->fieldNotExists('job');
}