You are here

public function ElementsTableSelectTest::testMultipleTrueSubmit 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::testMultipleTrueSubmit()
  2. 9 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testMultipleTrueSubmit()

Tests the submission of single and multiple values when #multiple is TRUE.

File

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

Class

ElementsTableSelectTest
Tests the tableselect form element for expected behavior.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testMultipleTrueSubmit() {

  // Test a submission with one checkbox checked.
  $edit = [];
  $edit['tableselect[row1]'] = TRUE;
  $this
    ->drupalGet('form_test/tableselect/multiple-true');
  $this
    ->submitForm($edit, 'Submit');
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->pageTextContains('Submitted: row1 = row1');
  $assert_session
    ->pageTextContains('Submitted: row2 = 0');
  $assert_session
    ->pageTextContains('Submitted: row3 = 0');

  // Test a submission with multiple checkboxes checked.
  $edit['tableselect[row1]'] = TRUE;
  $edit['tableselect[row3]'] = TRUE;
  $this
    ->drupalGet('form_test/tableselect/multiple-true');
  $this
    ->submitForm($edit, 'Submit');
  $assert_session
    ->pageTextContains('Submitted: row1 = row1');
  $assert_session
    ->pageTextContains('Submitted: row2 = 0');
  $assert_session
    ->pageTextContains('Submitted: row3 = row3');
}