function ElementsTableSelectTest::testMultipleTrueSubmit

Same name and namespace in other branches
  1. 8.9.x 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()
  3. 11.x 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 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->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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.