You are here

public function FormStateTest::testGetError in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testGetError()
  2. 10 core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testGetError()

Tests the getError() method.

@covers ::getError

@dataProvider providerTestGetError

File

core/tests/Drupal/Tests/Core/Form/FormStateTest.php, line 78
Contains \Drupal\Tests\Core\Form\FormStateTest.

Class

FormStateTest
@coversDefaultClass \Drupal\Core\Form\FormState

Namespace

Drupal\Tests\Core\Form

Code

public function testGetError($errors, $parents, $error = NULL) {
  $element['#parents'] = $parents;
  $form_state = (new FormState())
    ->setFormState([
    'errors' => $errors,
  ]);
  $this
    ->assertSame($error, $form_state
    ->getError($element));
}