function ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::testExposedFormRenderCheckboxes()
  3. 10 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 87

Class

ExposedFormCheckboxesTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testExposedFormRenderCheckboxes() : void {
    // 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('The submitted value in the Type element is not allowed.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.