Skip to content

CompatFormTest: Debug why the actual result is empty when fieldset contains a checkbox? #326

@sukhwinder33445

Description

@sukhwinder33445

I noticed that the following test's actual result is empty when the fieldset contains a checkbox.

The form works fine in real usage, both via Form::assemble() and in inline forms (as in example below).

public function testMethodApplyDefaultElementDecorators(): void
{
    // A fieldset, a required checkbox, and a submit button should cover
    // all default element decorators.
    $form = new CompatForm();
    $form->applyDefaultElementDecorators();

    $fieldset = $form->createElement('fieldset', 'foo', [
        'label' => 'Fieldset Label',
        'description' => 'Fieldset Description',
        'id' => 'foo-id'
    ]);

    // Comment out the code below fixes the issue
    // vvvvvvvvvvvvvvvvv
    $fieldset->addElement('checkbox', 'fooAndBar', [
        'label' => 'Fieldset Label',
        'description' => 'Fieldset Description',
        'id' => 'fooAndBar-id'
    ]);
    $form->addElement($fieldset);

    // ^^^^^^^^^^^^^^^^^^^
    
    $form->addElement('submit', 'submit_form', ['label' => 'Submit Form']);

    $expected = <<<'HTML'
    <form class="icinga-form icinga-controls" method="POST">
      SOMETHING
    </form>
HTML;

    $this->assertHtml($expected, $form);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions