final class OliveroHexToHslTest in Drupal 10
Tests the _olivero_hex_to_hsl() function.
@group olivero
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitWarnings
- class \Drupal\Tests\olivero\Unit\OliveroHexToHslTest
Expanded class hierarchy of OliveroHexToHslTest
File
- core/
themes/ olivero/ tests/ src/ Unit/ OliveroHexToHslTest.php, line 12
Namespace
Drupal\Tests\olivero\UnitView source
final class OliveroHexToHslTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public function setUp() : void {
parent::setUp();
require_once __DIR__ . '/../../../olivero.theme';
}
/**
* Tests hex to HSL conversion.
*
* @param string $hex
* The hex code.
* @param array $expected_hsl
* The expected HSL values.
*
* @dataProvider hexCodes
*/
public function testHexToHsl(string $hex, array $expected_hsl) : void {
self::assertEquals($expected_hsl, _olivero_hex_to_hsl($hex));
}
/**
* Data provider of hex codes and HSL values.
*
* @return array[]
* The test data.
*/
public function hexCodes() : array {
return [
'Blue Lagoon' => [
'#1b9ae4',
[
202,
79,
50,
],
],
'Firehouse' => [
'#a30f0f',
[
0,
83,
35,
],
],
'Ice' => [
'#57919e',
[
191,
29,
48,
],
],
'Plum' => [
'#7a4587',
[
288,
32,
40,
],
],
'Slate' => [
'#47625b',
[
164,
16,
33,
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OliveroHexToHslTest:: |
public | function | Data provider of hex codes and HSL values. | |
OliveroHexToHslTest:: |
public | function |
Overrides UnitTestCase:: |
|
OliveroHexToHslTest:: |
public | function | Tests hex to HSL conversion. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
public static | function |