function FieldConfigEditFormTest::providerRequired

Same name in other branches
  1. 11.x core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php \Drupal\Tests\field_ui\Unit\FieldConfigEditFormTest::providerRequired()

Provides test cases with required and optional elements.

File

core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php, line 55

Class

FieldConfigEditFormTest
@coversDefaultClass \Drupal\field_ui\Form\FieldConfigEditForm

Namespace

Drupal\Tests\field_ui\Unit

Code

public static function providerRequired() : \Generator {
    (yield 'required' => [
        [
            [
                '#required' => TRUE,
            ],
        ],
        TRUE,
    ]);
    (yield 'optional' => [
        [
            [
                '#required' => FALSE,
            ],
        ],
        FALSE,
    ]);
    (yield 'required and optional' => [
        [
            [
                '#required' => TRUE,
            ],
            [
                '#required' => FALSE,
            ],
        ],
        TRUE,
    ]);
    (yield 'empty' => [
        [
            [],
            [],
        ],
        FALSE,
    ]);
    (yield 'multiple required' => [
        [
            [
                [
                    '#required' => TRUE,
                ],
            ],
            [
                [
                    '#required' => TRUE,
                ],
            ],
        ],
        TRUE,
    ]);
    (yield 'multiple optional' => [
        [
            [
                [
                    '#required' => FALSE,
                ],
            ],
            [
                [
                    '#required' => FALSE,
                ],
            ],
        ],
        FALSE,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.