function ComponentMetadataTest::dataProviderEnumOptionsMetadata

File

core/tests/Drupal/Tests/Core/Theme/Component/ComponentMetadataTest.php, line 380

Class

ComponentMetadataTest
Unit tests for the component metadata class.

Namespace

Drupal\Tests\Core\Theme\Component

Code

public static function dataProviderEnumOptionsMetadata() : array {
    $common_schema = [
        '$schema' => 'https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json',
        'id' => 'core:my-button',
        'machineName' => 'my-button',
        'path' => 'foo/my-other/path',
        'name' => 'Button',
    ];
    return [
        'no meta:enum' => [
            $common_schema + [
                'props' => [
                    'type' => 'object',
                    'required' => [
                        'text',
                    ],
                    'properties' => [
                        'iconType' => [
                            'type' => 'string',
                            'title' => 'Icon Type',
                            'enum' => [
                                'power',
                                'like',
                                'external',
                            ],
                        ],
                    ],
                ],
            ],
            'iconType',
            [
                'power' => 'power',
                'like' => 'like',
                'external' => 'external',
            ],
            '',
        ],
        'meta:enum, with x-translation-context' => [
            $common_schema + [
                'props' => [
                    'type' => 'object',
                    'required' => [
                        'text',
                    ],
                    'properties' => [
                        'target' => [
                            'type' => 'string',
                            'title' => 'Icon Type',
                            'enum' => [
                                '',
                                '_blank',
                            ],
                            'meta:enum' => [
                                '' => 'Opens in same window',
                                '_blank' => 'Opens in new window',
                            ],
                            'x-translation-context' => 'Link target',
                        ],
                    ],
                ],
            ],
            'target',
            [
                '' => 'Opens in same window',
                '_blank' => 'Opens in new window',
            ],
            'Link target',
        ],
    ];
}

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