You are here

public function GroupLimitValidationTest::testFormValidation in Search API Grouping 8

Test the validation of the processor form.

File

tests/src/Unit/GroupLimitValidationTest.php, line 30

Class

GroupLimitValidationTest
Test the getSupportedFields method.

Namespace

Drupal\Tests\search_api_grouping\Unit

Code

public function testFormValidation() {

  // Insert an integer as value.
  $form['group_limit']['#value'] = "3";
  $form['group_limit']['#title'] = 'Form';
  $form['group_limit']['#parents'] = [];
  $form_state = (new FormState())
    ->setValue('group_limit', 3);
  $this->processor
    ->validateConfigurationForm($form, $form_state);
  $this
    ->assertFalse($form_state
    ->hasAnyErrors());

  // Insert a non integer.
  $form['group_limit']['#value'] = "3.2";
  $this->processor
    ->validateConfigurationForm($form, $form_state);
  $this
    ->assertTrue($form_state
    ->hasAnyErrors());
}