public function ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes()
- 9 core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes()
Tests overriding the default render option with checkboxes.
File
- core/
modules/ views/ tests/ src/ Functional/ Plugin/ ExposedFormCheckboxesTest.php, line 85
Class
- ExposedFormCheckboxesTest
- Tests exposed forms functionality.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testExposedFormRenderCheckboxes() {
// Use a test theme to convert multi-select elements into checkboxes.
\Drupal::service('theme_installer')
->install([
'views_test_checkboxes_theme',
]);
$this
->config('system.theme')
->set('default', 'views_test_checkboxes_theme')
->save();
// Only display 5 items per page so we can test that paging works.
$view = Views::getView('test_exposed_form_checkboxes');
$display =& $view->storage
->getDisplay('default');
$display['display_options']['pager']['options']['items_per_page'] = 5;
$view
->save();
$this
->drupalGet('test_exposed_form_checkboxes');
$this
->assertSame('checkbox', $this
->assertSession()
->fieldExists('type[article]')
->getAttribute('type'));
$this
->assertSame('checkbox', $this
->assertSession()
->fieldExists('type[page]')
->getAttribute('type'));
// Ensure that all results are displayed.
// 5 rows are displayed by default on the first page when no options are
// checked.
$this
->assertSession()
->elementsCount('xpath', "//div[contains(@class, 'views-row')]", 5);
// 1 row is displayed by default on the second page when no options are
// checked.
$this
->clickLink('Page 2');
$this
->assertSession()
->elementsCount('xpath', "//div[contains(@class, 'views-row')]", 1);
$this
->assertSession()
->pageTextNotContains('An illegal choice has been detected. Please contact the site administrator.');
}