You are here

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

Expanded class hierarchy of OliveroHexToHslTest

File

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

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 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

Namesort descending Modifiers Type Description Overrides
OliveroHexToHslTest::hexCodes public 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.
UnitTestCase::$randomGenerator protected property The random generator.
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::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function