function ComponentValidatorTest::testValidatePropsValid

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

Tests that valid props are handled properly.

@dataProvider dataProviderValidatePropsValid

Throws

\Drupal\Core\Render\Component\Exception\InvalidComponentException

File

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

Class

ComponentValidatorTest
Unit tests for the component validation.

Namespace

Drupal\Tests\Core\Theme\Component

Code

public function testValidatePropsValid(array $context, string $component_id, array $definition) : void {
    $component = new Component([
        'app_root' => '/fake/path/root',
    ], 'sdc_test:' . $component_id, $definition);
    $component_validator = new ComponentValidator();
    $component_validator->setValidator();
    $this->assertTrue($component_validator->validateProps($context, $component), 'The valid component props threw an error.');
}

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