public function ElementsTableSelectTest::testMultipleTrueOptionchecker in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testMultipleTrueOptionchecker()
- 10 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testMultipleTrueOptionchecker()
Tests the whether the option checker gives an error on invalid tableselect values for checkboxes.
File
- core/
modules/ system/ tests/ src/ Functional/ Form/ ElementsTableSelectTest.php, line 157
Class
- ElementsTableSelectTest
- Tests the tableselect form element for expected behavior.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testMultipleTrueOptionchecker() {
list($header, $options) = _form_test_tableselect_get_data();
$form['tableselect'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
];
// Test with a valid value.
list(, , $errors) = $this
->formSubmitHelper($form, [
'tableselect' => [
'row1' => 'row1',
],
]);
$this
->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for checkboxes.');
// Test with an invalid value.
list(, , $errors) = $this
->formSubmitHelper($form, [
'tableselect' => [
'non_existing_value' => 'non_existing_value',
],
]);
$this
->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for checkboxes.');
}