1 form.test FormsElementsTableSelectFunctionalTest::testAdvancedSelect()

Test the #js_select property.

File

core/modules/simpletest/tests/form.test, line 1090
Unit tests for the Backdrop Form API.

Class

FormsElementsTableSelectFunctionalTest
Test the tableselect form element for expected behavior.

Code

function testAdvancedSelect() {
  // When #multiple = TRUE a Select all checkbox should be displayed by default.
  $this->backdropGet('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->backdropGet('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->backdropGet('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->backdropGet('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.');
}