class OliveroHexToHslTest

Same name in other branches
  1. 10 core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php \Drupal\Tests\olivero\Unit\OliveroHexToHslTest

Tests the _olivero_hex_to_hsl() function.

@group olivero

Hierarchy

Expanded class hierarchy of OliveroHexToHslTest

File

core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php, line 14

Namespace

Drupal\Tests\olivero\Unit
View 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 Modifiers Object type Summary Overriden Title
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::getCallableName private static function Returns a callable as a string suitable for inclusion in a message.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
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.
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::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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.