NumberTest.php
Same filename in this branch
Same filename and directory in other branches
Namespace
Drupal\Tests\Core\Theme\DesignToken\PluginFile
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ NumberTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\Core\Theme\DesignToken\Plugin;
use Drupal\Core\Theme\Plugin\DesignTokenValue\Number;
use Drupal\Tests\Core\Theme\DesignToken\DesignTokenValuePluginTestBase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
/**
* Tests number value plugin.
*/
class NumberTest extends DesignTokenValuePluginTestBase {
/**
* {@inheritdoc}
*/
protected string $pluginId = 'number';
/**
* {@inheritdoc}
*/
public function testToDtcg(mixed $value, mixed $expected) : void {
$configuration = [
'value' => $value,
];
$plugin = new Number($configuration, $this->pluginId, []);
$this->assertSame($expected, $plugin->toDtcg());
}
/**
* Data provider for ::testToDtcg().
*
* @return \Generator
* The test cases.
*/
public static function providerToDtcg() : iterable {
yield 'integer' => [
50,
50,
];
yield 'float' => [
4.2,
4.2,
];
}
/**
* {@inheritdoc}
*/
public function testToCss(mixed $value, string $expected) : void {
$configuration = [
'value' => $value,
];
$plugin = new Number($configuration, $this->pluginId, []);
$this->assertSame($expected, $plugin->toCss());
}
/**
* Data provider for ::testToCss().
*
* @return \Generator
* The test cases.
*/
public static function providerToCss() : iterable {
yield 'integer' => [
50,
'50',
];
yield 'float' => [
4.2,
'4.2',
];
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| NumberTest | Tests number value plugin. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.