function ComponentValidatorTest::loadComponentDefinitionFromFs

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

Loads a component definition from the component name.

Parameters

string $component_name: The component name.

Return value

array The component definition

3 calls to ComponentValidatorTest::loadComponentDefinitionFromFs()
ComponentValidatorTest::dataProviderValidateDefinitionInvalid in core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
Data provider with invalid component definitions.
ComponentValidatorTest::dataProviderValidatePropsInvalid in core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
Data provider with invalid component props.
ComponentValidatorTest::dataProviderValidatePropsValid in core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
Data provider with valid component props.

File

core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php, line 218

Class

ComponentValidatorTest
Unit tests for the component validation.

Namespace

Drupal\Tests\Core\Theme\Component

Code

private static function loadComponentDefinitionFromFs(string $component_name) : array {
    return array_merge(Yaml::parseFile(sprintf('%s/modules/system/tests/modules/sdc_test/components/%s/%s.component.yml', dirname(__DIR__, 6), $component_name, $component_name)), [
        'machineName' => $component_name,
        'extension_type' => 'module',
        'id' => 'sdc_test:' . $component_name,
        'library' => [
            'css' => [
                'component' => [
                    'foo.css' => [],
                ],
            ],
        ],
        'path' => '',
        'provider' => 'sdc_test',
        'template' => $component_name . '.twig',
        'group' => 'my-group',
        'description' => 'My description',
    ]);
}

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