diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
index b37d6bba44b45bd91420a0ef565e457f0511b0a2..5d7d79b051d5ed6a50b1f1fa0c98b06050394192 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
@@ -37,6 +37,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $required
       '#type' => 'textfield',
       '#title' => 'Nest in container element',
     ];
+    $form['fieldset_zero'] = [
+      '#type' => 'fieldset',
+      '#title' => 0,
+    ];
     return $form;
   }
 
diff --git a/core/modules/system/tests/src/Functional/Form/ElementTest.php b/core/modules/system/tests/src/Functional/Form/ElementTest.php
index dc11b26093609bf2de58a6c19c920d0fd5dae764..afd264577a87f992574ebb91d68c9691e096d68d 100644
--- a/core/modules/system/tests/src/Functional/Form/ElementTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php
@@ -144,6 +144,7 @@ public function testGroupElements() {
     $this->assertSession()->elementsCount('xpath', '//div[@id="edit-container"]//div[@class="details-wrapper"]//label', 1);
     $this->drupalGet('form-test/group-fieldset');
     $this->assertSession()->elementsCount('xpath', '//fieldset[@id="edit-fieldset"]//div[@id="edit-meta"]//label', 1);
+    $this->assertSession()->elementTextEquals('xpath', '//fieldset[@id="edit-fieldset-zero"]//legend', '0');
     $this->drupalGet('form-test/group-vertical-tabs');
     $this->assertSession()->elementsCount('xpath', '//div[@data-vertical-tabs-panes]//details[@id="edit-meta"]//label', 1);
     $this->assertSession()->elementsCount('xpath', '//div[@data-vertical-tabs-panes]//details[@id="edit-meta-2"]//label', 1);