Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
#2880011: Add a #disable_inline_form_errors_summary property to disable the Inline Form Errors summary needs refactoring of test FormErrorHandlerTest.
Add one form in the Setup with fields for various test cases (e.g. missing or invisible fields) and use it in every tests.
protected function setUp() {
parent::setUp();
$form = [
'#parents' => [],
'#form_id' => 'test_form',
'#array_parents' => [],
];
$form['test1'] = [
'#type' => 'textfield',
'#title' => 'Test 1',
'#parents' => ['test1'],
'#array_parents' => ['test1'],
'#id' => 'edit-test1',
];
(...)
$form['test6'] = [
'#type' => 'value',
'#title' => 'Test 6',
'#parents' => ['test6'],
'#array_parents' => ['test6'],
'#id' => 'edit-test6',
];
$this->form = $form;
Proposed resolution
Use the existing form from the testDisplayErrorMessagesInline()
.
Remove testSetElementErrorsFromFormState()
. It does not seem to be necessary. It's covered in testDisplayErrorMessagesInline()
!
Comment | File | Size | Author |
---|---|---|---|
#5 | core_3027318-5.patch | 9.33 KB | Krzysztof Domański |
#5 | interdiff-2-5.txt | 4.79 KB | Krzysztof Domański |
Comments
Comment #2
Krzysztof DomańskiComment #3
Krzysztof DomańskiComment #4
wengerkThanks to @Krzysztof Domański for addressing this blocker issue from #2880011: Add a #disable_inline_form_errors_summary property to disable the Inline Form Errors summary !
I still think there is room for improvement, but these are minor points.
$form
property could be more "explicite" as it's only used for tests purpose.I would suggest sommething such:
inheritdoc
for$modules
property.$this->form
instead of doing$this->form = $form;
?testErrorMessagesNotInline
seems wrong.This method disable the inline_form_error but we still have:
This don't assert the inline message when
#disable_inline_form_errors
is used. It only assert the error belongs to the correct input.I think we can keep this
$this->assertSame('invalid', $this->form['test1']['#errors']);
on both Test, but we have to change the comment to reflect it only assert#error
is populated for proper input.Comment #5
Krzysztof DomańskiI add the changes suggested by #4.
I'm not sure about 4.3. Is
$modules
property required here? Does not exist in FormErrorHandlerTest.Comment #6
wengerkRight, I think I miss review by seeing it in another file cause there is not $modules in your code haha sorry.
Seems good to me, let's see what people think about it !
Comment #7
wengerkComment #9
mpp CreditAttribution: mpp at District09 for District09 commentedLooks good.
Let's move this forward so we can fix #2880011 as well.
Comment #10
alexpottCommitted and pushed 1debb36c1a to 8.8.x and 7460ad9745 to 8.7.x. Thanks!
As a test-only change backported to 8.7.x to keep the branches aligned.