class DesignTokenValidationTest
Tests validation of design_token entities.
Attributes
#[Group('design_token')]
#[Group('config')]
#[Group('Validation')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Theme\DesignToken\DesignTokenValidationTest extends \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of DesignTokenValidationTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenValidationTest.php, line 15
Namespace
Drupal\KernelTests\Core\Theme\DesignTokenView source
class DesignTokenValidationTest extends ConfigEntityValidationTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$values = [
'id' => 'my_id',
'path' => 'foo.bar.baz',
'type' => 'dimension',
'scopes' => [
':root' => [
'value' => 12,
'unit' => 'px',
],
'.card' => [
'value' => 14,
'unit' => 'rem',
],
'%breadcrumb' => [
'value' => 14,
'unit' => 'rem',
],
],
];
$this->entity = DesignToken::create($values);
$this->entity
->save();
}
/**
* {@inheritdoc}
*/
public function testImmutableProperties(array $valid_values = []) : void {
// If we don't clear the previous scopes here, we will get unrelated
// validation errors (in addition to the one we're expecting), because the
// scopes from the *old* type won't match the config schema for the
// scopes of the *new* type.
$this->entity
->set('scopes', []);
parent::testImmutableProperties([
'type' => 'fontWeight',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.