function ElementsTableSelectTest::testAdvancedSelect

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testAdvancedSelect()
  2. 8.9.x core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testAdvancedSelect()
  3. 11.x core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testAdvancedSelect()

Tests the #js_select property.

File

core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php, line 136

Class

ElementsTableSelectTest
Tests the tableselect form element for expected behavior.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testAdvancedSelect() : void {
    // When #multiple = TRUE a Select all checkbox should be displayed by default.
    $this->drupalGet('form_test/tableselect/advanced-select/multiple-true-default');
    $this->assertSession()
        ->elementExists('xpath', '//th[@class="select-all"]');
    // When #js_select is set to FALSE, a "Select all" checkbox should not be displayed.
    $this->drupalGet('form_test/tableselect/advanced-select/multiple-true-no-advanced-select');
    $this->assertSession()
        ->elementNotExists('xpath', '//th[@class="select-all"]');
    // A "Select all" checkbox never makes sense when #multiple = FALSE, regardless of the value of #js_select.
    $this->drupalGet('form_test/tableselect/advanced-select/multiple-false-default');
    $this->assertSession()
        ->elementNotExists('xpath', '//th[@class="select-all"]');
    $this->drupalGet('form_test/tableselect/advanced-select/multiple-false-advanced-select');
    $this->assertSession()
        ->elementNotExists('xpath', '//th[@class="select-all"]');
}

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