function ComponentMetadataTest::testMetadataEnforceSchema

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

Tests the correct checks when enforcing schemas or not.

@dataProvider dataProviderMetadata

File

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

Class

ComponentMetadataTest
Unit tests for the component metadata class.

Namespace

Drupal\Tests\sdc\Unit

Code

public function testMetadataEnforceSchema(array $metadata_info, array $expectations, bool $missing_schema) {
    if ($missing_schema) {
        $this->expectException(InvalidComponentException::class);
        $this->expectExceptionMessage('The component "' . $metadata_info['id'] . '" does not provide schema information. Schema definitions are mandatory for components declared in modules. For components declared in themes, schema definitions are only mandatory if the "enforce_prop_schemas" key is set to "true" in the theme info file.');
        new ComponentMetadata($metadata_info, 'foo/', TRUE);
    }
    else {
        new ComponentMetadata($metadata_info, 'foo/', TRUE);
        $this->expectNotToPerformAssertions();
    }
}

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