function ComponentMetadataTest::dataProviderMetadata

Same name in this branch
  1. 11.x core/tests/Drupal/Tests/Core/Theme/Component/ComponentMetadataTest.php \Drupal\Tests\Core\Theme\Component\ComponentMetadataTest::dataProviderMetadata()
Same name and namespace in other branches
  1. 10 core/modules/sdc/tests/src/Unit/ComponentMetadataTest.php \Drupal\Tests\sdc\Unit\ComponentMetadataTest::dataProviderMetadata()

Data provider for the test testMetadataEnforceSchema.

Return value

array[] The batches of data.

File

core/modules/sdc/tests/src/Unit/ComponentMetadataTest.php, line 57

Class

ComponentMetadataTest
Unit tests for the component metadata class.

Namespace

Drupal\Tests\sdc\Unit

Code

public static function dataProviderMetadata() : array {
    return [
        'minimal example without schemas' => [
            [
                'path' => 'foo/bar/component-name',
                'id' => 'sdc:component-name',
                'name' => 'Component Name',
                'libraryOverrides' => [
                    'dependencies' => [
                        'core/drupal',
                    ],
                ],
                'group' => 'my-group',
                'description' => 'My description',
            ],
            [
                'path' => 'bar/component-name',
                'status' => 'stable',
                'thumbnail' => '',
                'props' => NULL,
            ],
            TRUE,
        ],
        'complete example with schema' => [
            [
                '$schema' => 'https://git.drupalcode.org/project/sdc/-/raw/1.x/src/metadata.schema.json',
                'id' => 'sdc:my-button',
                'machineName' => 'my-button',
                'path' => 'foo/my-other/path',
                'name' => 'Button',
                'description' => 'JavaScript enhanced button that tracks the number of times a user clicked it.',
                'libraryOverrides' => [
                    'dependencies' => [
                        'core/drupal',
                    ],
                ],
                'group' => 'my-group',
                'props' => [
                    'type' => 'object',
                    'required' => [
                        'text',
                    ],
                    'properties' => [
                        'text' => [
                            'type' => 'string',
                            'title' => 'Title',
                            'description' => 'The title for the button',
                            'minLength' => 2,
                            'examples' => [
                                'Press',
                                'Submit now',
                            ],
                        ],
                        'iconType' => [
                            'type' => 'string',
                            'title' => 'Icon Type',
                            'enum' => [
                                'power',
                                'like',
                                'external',
                            ],
                        ],
                    ],
                ],
            ],
            [
                'path' => 'my-other/path',
                'status' => 'stable',
                'thumbnail' => '',
                'group' => 'my-group',
                'additionalProperties' => FALSE,
                'props' => [
                    'type' => 'object',
                    'required' => [
                        'text',
                    ],
                    'additionalProperties' => FALSE,
                    'properties' => [
                        'text' => [
                            'type' => [
                                'string',
                                'object',
                            ],
                            'title' => 'Title',
                            'description' => 'The title for the button',
                            'minLength' => 2,
                            'examples' => [
                                'Press',
                                'Submit now',
                            ],
                        ],
                        'iconType' => [
                            'type' => [
                                'string',
                                'object',
                            ],
                            'title' => 'Icon Type',
                            'enum' => [
                                'power',
                                'like',
                                'external',
                            ],
                        ],
                    ],
                ],
            ],
            FALSE,
        ],
    ];
}

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