class OliveroHexToHslTest
Same name and namespace in other branches
- 10 core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php \Drupal\Tests\olivero\Unit\OliveroHexToHslTest
- 11.x core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php \Drupal\Tests\olivero\Unit\OliveroHexToHslTest
Tests the \Drupal\olivero\HexToHslTrait:convertHexToHsl() function.
Attributes
#[Group('olivero')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\olivero\Unit\OliveroHexToHslTest uses \Drupal\olivero\HexToHslTrait extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of OliveroHexToHslTest
File
-
core/
themes/ olivero/ tests/ src/ Unit/ OliveroHexToHslTest.php, line 15
Namespace
Drupal\Tests\olivero\UnitView source
final class OliveroHexToHslTest extends UnitTestCase {
use HexToHslTrait;
/**
* Tests hex to HSL conversion.
*
* @param string $hex
* The hex code.
* @param array $expected_hsl
* The expected HSL values.
*/
public function testHexToHsl(string $hex, array $expected_hsl) : void {
self::assertEquals($expected_hsl, $this->convertHexToHsl($hex));
}
/**
* Data provider of hex codes and HSL values.
*
* @return array[]
* The test data.
*/
public static 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
| Title Sort descending | Modifiers | Object type | Summary | Overrides |
|---|---|---|---|---|
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 |
| HexToHslTrait::convertHexToHsl | protected | function | Converts hex color strings to array of HSL values. | |
| OliveroHexToHslTest::hexCodes | public static | function | Data provider of hex codes and HSL values. | |
| OliveroHexToHslTest::testHexToHsl | public | function | Tests hex to HSL conversion. | |
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
| UnitTestCase::$root | protected | property | The app root. | |
| UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
| UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |
| UnitTestCase::setUp | protected | function | 355 | |
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.