class FormElementInlineErrorTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/inline_form_errors/tests/src/Kernel/FormElementInlineErrorTest.php \Drupal\Tests\inline_form_errors\Kernel\FormElementInlineErrorTest
- 9 core/modules/inline_form_errors/tests/src/Kernel/FormElementInlineErrorTest.php \Drupal\Tests\inline_form_errors\Kernel\FormElementInlineErrorTest
Tests messages on form elements.
@group InlineFormErrors
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\inline_form_errors\Kernel\FormElementInlineErrorTest
Expanded class hierarchy of FormElementInlineErrorTest
File
- core/
modules/ inline_form_errors/ tests/ src/ Kernel/ FormElementInlineErrorTest.php, line 13
Namespace
Drupal\Tests\inline_form_errors\KernelView source
class FormElementInlineErrorTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'inline_form_errors',
];
/**
* Tests that no inline form errors are shown when disabled for a form.
*/
public function testDisplayErrorMessagesNotInline() {
$form_id = 'test';
$form = [
'#parents' => [],
'#disable_inline_form_errors' => TRUE,
'#array_parents' => [],
];
$form['test'] = [
'#type' => 'textfield',
'#title' => 'Test',
'#parents' => [
'test',
],
'#id' => 'edit-test',
'#array_parents' => [
'test',
],
];
$form_state = new FormState();
\Drupal::formBuilder()
->prepareForm($form_id, $form, $form_state);
\Drupal::formBuilder()
->processForm($form_id, $form, $form_state);
// Just test if the #error_no_message property is TRUE. FormErrorHandlerTest
// tests if the property actually hides the error message.
$this
->assertTrue($form['test']['#error_no_message']);
}
}