You are here

function ElementsTableSelectTest::testAdvancedSelect in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Form/ElementsTableSelectTest.php \Drupal\system\Tests\Form\ElementsTableSelectTest::testAdvancedSelect()

Test the #js_select property.

File

core/modules/system/src/Tests/Form/ElementsTableSelectTest.php, line 132
Contains \Drupal\system\Tests\Form\ElementsTableSelectTest.

Class

ElementsTableSelectTest
Tests the tableselect form element for expected behavior.

Namespace

Drupal\system\Tests\Form

Code

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
    ->assertFieldByXPath('//th[@class="select-all"]', NULL, 'Display a "Select all" checkbox by default when #multiple is TRUE.');

  // 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
    ->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #js_select is FALSE.');

  // 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
    ->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #multiple is FALSE.');
  $this
    ->drupalGet('form_test/tableselect/advanced-select/multiple-false-advanced-select');
  $this
    ->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #multiple is FALSE, even when #js_select is TRUE.');
}