public function FormErrorHandlerTest::testSetElementErrorsFromFormState in Zircon Profile 8.0
Same name in this branch
- 8.0 core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::testSetElementErrorsFromFormState()
- 8.0 core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::testSetElementErrorsFromFormState()
Same name and namespace in other branches
- 8 core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::testSetElementErrorsFromFormState()
@covers ::handleFormErrors @covers ::setElementErrorsFromFormState
File
- core/
modules/ inline_form_errors/ tests/ src/ Unit/ FormErrorHandlerTest.php, line 114 - Contains \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest.
Class
- FormErrorHandlerTest
- @coversDefaultClass \Drupal\inline_form_errors\FormErrorHandler @group InlineFormErrors
Namespace
Drupal\Tests\inline_form_errors\UnitCode
public function testSetElementErrorsFromFormState() {
$form_error_handler = $this
->getMockBuilder(FormErrorHandler::class)
->setConstructorArgs([
$this
->getStringTranslationStub(),
$this
->getMock(LinkGeneratorInterface::class),
$this
->getMock(RendererInterface::class),
])
->setMethods([
'drupalSetMessage',
])
->getMock();
$form = [
'#parents' => [],
];
$form['test'] = [
'#type' => 'textfield',
'#title' => 'Test',
'#parents' => [
'test',
],
'#id' => 'edit-test',
];
$form_state = new FormState();
$form_state
->setErrorByName('test', 'invalid');
$form_error_handler
->handleFormErrors($form, $form_state);
$this
->assertSame('invalid', $form['test']['#errors']);
}