public function CToolsViewsBasicViewBlockTest::testHideFields in Chaos Tool Suite (ctools) 8.3
Test ctools_views 'hide_fields' configuration.
File
- modules/
ctools_views/ tests/ src/ Functional/ CToolsViewsBasicViewBlockTest.php, line 202
Class
- CToolsViewsBasicViewBlockTest
- Tests ctools_views block display plugin overrides settings from a basic View.
Namespace
Drupal\Tests\ctools_views\FunctionalCode
public function testHideFields() {
$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_fields/' . $default_theme);
$this
->assertSession()
->fieldExists('edit-settings-override-order-fields-id-hide');
// Add block to sidebar_first region with default settings.
$edit = [];
$edit['region'] = 'sidebar_first';
$this
->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_fields/' . $default_theme, $edit, $this
->t('Save block'));
// Assert hide_fields default settings.
$this
->drupalGet('<front>');
$this
->assertEquals(5, count($this
->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//td[contains(@class, "views-field-id")]')));
// Override hide_fields settings.
$edit = [];
$edit['region'] = 'sidebar_first';
$edit['settings[override][order_fields][id][hide]'] = 1;
$this
->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_fields', $edit, $this
->t('Save block'));
$block = $this->storage
->load('views_block__ctools_views_test_view_block_fields');
$config = $block
->getPlugin()
->getConfiguration();
$this
->assertEquals(1, $config['fields']['id']['hide'], "'hide_fields' setting is properly saved.");
$this
->assertEquals(0, $config['fields']['name']['hide'], "'hide_fields' setting is properly saved.");
// Assert hide_fields overridden settings.
$this
->drupalGet('<front>');
$this
->assertEquals(0, count($this
->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//td[contains(@class, "views-field-id")]')));
}