function CToolsViewsBasicViewBlockTest::testConfigureSorts
Same name in other branches
- 4.0.x modules/ctools_views/tests/src/Functional/CToolsViewsBasicViewBlockTest.php \Drupal\Tests\ctools_views\Functional\CToolsViewsBasicViewBlockTest::testConfigureSorts()
Test ctools_views 'configure_sorts' configuration.
File
-
modules/
ctools_views/ tests/ src/ Functional/ CToolsViewsBasicViewBlockTest.php, line 384
Class
- CToolsViewsBasicViewBlockTest
- Tests ctools_views block display plugin overrides settings from a basic View.
Namespace
Drupal\Tests\ctools_views\FunctionalCode
public function testConfigureSorts() {
$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_sort/' . $default_theme);
$this->assertSession()
->fieldExists('settings[override][sort][id][order]');
// Add block to sidebar_first region with default settings.
$edit = [];
$edit['region'] = 'sidebar_first';
$edit['id'] = 'views_block__ctools_views_test_view_block_sort';
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_sort/' . $default_theme);
$this->submitForm($edit, 'Save block');
// Assert configure_sorts default settings.
$this->drupalGet('<front>');
// Check that the results are sorted ASC.
$element = $this->xpath('//div[contains(@class, "view-display-id-block_sort")]//table//tr[1]/td[1]');
$value = $element[0]->getText();
$this->assertEquals('1', trim($value));
// Override configure_sorts settings.
$edit = [];
$edit['region'] = 'sidebar_first';
$edit['settings[override][sort][id][order]'] = 'DESC';
$this->drupalGet('admin/structure/block/manage/views_block__ctools_views_test_view_block_sort');
$this->submitForm($edit, 'Save block');
$block = $this->storage
->load('views_block__ctools_views_test_view_block_sort');
$config = $block->getPlugin()
->getConfiguration();
$this->assertEquals('DESC', $config['sort']['id'], "'configure_sorts' setting is properly saved.");
// Assert configure_sorts overridden settings.
// Check that the results are sorted DESC.
$this->drupalGet('<front>');
$element = $this->xpath('//div[contains(@class, "view-display-id-block_sort")]//table//tr[1]/td[1]');
$value = $element[0]->getText();
$this->assertEquals('5', trim($value));
}