You are here

public function ElementsTableSelectTest::testAdvancedSelect in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testAdvancedSelect()
  2. 9 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() {

  // 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"]');
}