class FontFamilyTest
Tests font family value plugin.
Attributes
#[CoversClass(FontFamily::class)]
#[Group('design_token')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Theme\DesignToken\DesignTokenValuePluginTestBase extends \Drupal\Tests\UnitTestCase
- class \Drupal\Tests\Core\Theme\DesignToken\Plugin\FontFamilyTest extends \Drupal\Tests\Core\Theme\DesignToken\DesignTokenValuePluginTestBase
- class \Drupal\Tests\Core\Theme\DesignToken\DesignTokenValuePluginTestBase extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of FontFamilyTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ FontFamilyTest.php, line 16
Namespace
Drupal\Tests\Core\Theme\DesignToken\PluginView source
class FontFamilyTest extends DesignTokenValuePluginTestBase {
/**
* {@inheritdoc}
*/
protected string $pluginId = 'fontFamily';
/**
* {@inheritdoc}
*/
public function testToDtcg(mixed $value, mixed $expected) : void {
$this->assertIsArray($expected);
$configuration = [
'value' => $value,
];
$plugin = new FontFamily($configuration, $this->pluginId, []);
$this->assertSame($expected, $plugin->toDtcg());
}
/**
* Data provider for ::testToDtcg().
*
* @return \Generator
* The test cases.
*/
public static function providerToDtcg() : iterable {
yield 'string' => [
'Arial',
[
'Arial',
],
];
yield 'list' => [
[
'Arial',
'sans-serif',
],
[
'Arial',
'sans-serif',
],
];
}
/**
* {@inheritdoc}
*/
public function testToCss(mixed $value, string $expected) : void {
$configuration = [
'value' => $value,
];
$plugin = new FontFamily($configuration, $this->pluginId, []);
$this->assertSame($expected, $plugin->toCss());
}
/**
* Data provider for ::testToCss().
*
* @return \Generator
* The test cases.
*/
public static function providerToCss() : iterable {
yield 'string' => [
'Arial',
'Arial',
];
yield 'list' => [
[
'Arial',
'sans-serif',
],
'Arial, sans-serif',
];
yield 'XSS' => [
[
'Arial',
'<script>alert()</script>',
],
'Arial, <script>alert()</script>',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.