class OliveroHexToHslTest
Same name in other branches
- 11.x core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php \Drupal\Tests\olivero\Unit\OliveroHexToHslTest
Tests the _olivero_hex_to_hsl() function.
@group olivero
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\olivero\Unit\OliveroHexToHslTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of OliveroHexToHslTest
File
-
core/
themes/ olivero/ tests/ src/ Unit/ OliveroHexToHslTest.php, line 14
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 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 | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
OliveroHexToHslTest::hexCodes | public static | function | Data provider of hex codes and HSL values. | |||
OliveroHexToHslTest::setUp | public | function | Overrides UnitTestCase::setUp | |||
OliveroHexToHslTest::testHexToHsl | public | function | Tests hex to HSL conversion. | |||
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |||
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. | |||
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. | ||
UnitTestCase::$root | protected | property | The app root. | 1 | ||
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::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |||
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::setUpBeforeClass | public static | function | ||||
UnitTestCase::__get | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.