You are here

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

Test the whether the option checker gives an error on invalid tableselect values for radios.

File

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

Class

ElementsTableSelectTest
Tests the tableselect form element for expected behavior.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testMultipleFalseOptionchecker() {
  list($header, $options) = _form_test_tableselect_get_data();
  $form['tableselect'] = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#multiple' => FALSE,
  ];

  // Test with a valid value.
  list(, , $errors) = $this
    ->formSubmitHelper($form, [
    'tableselect' => 'row1',
  ]);
  $this
    ->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for radio buttons.');

  // Test with an invalid value.
  list(, , $errors) = $this
    ->formSubmitHelper($form, [
    'tableselect' => 'non_existing_value',
  ]);
  $this
    ->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for radio buttons.');
}