You are here

public function ElementsTableSelectTest::testMultipleTrueSubmit in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testMultipleTrueSubmit()
  2. 10 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testMultipleTrueSubmit()

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

File

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

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
    ->drupalPostForm('form_test/tableselect/multiple-true', $edit, 'Submit');
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->pageTextContains('Submitted: row1 = row1', 'Checked checkbox row1');
  $assert_session
    ->pageTextContains('Submitted: row2 = 0', 'Unchecked checkbox row2.');
  $assert_session
    ->pageTextContains('Submitted: row3 = 0', 'Unchecked checkbox row3.');

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