function ColorTest::providerTestValidateHex

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/ColorTest.php \Drupal\Tests\Component\Utility\ColorTest::providerTestValidateHex()
  2. 10 core/tests/Drupal/Tests/Component/Utility/ColorTest.php \Drupal\Tests\Component\Utility\ColorTest::providerTestValidateHex()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/ColorTest.php \Drupal\Tests\Component\Utility\ColorTest::providerTestValidateHex()

Provides data for testValidateHex().

File

core/tests/Drupal/Tests/Component/Utility/ColorTest.php, line 32

Class

ColorTest
Tests Color utility class conversions.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestValidateHex() {
    return [
        // Tests length.
[
            FALSE,
            '',
        ],
        [
            FALSE,
            '#',
        ],
        [
            FALSE,
            '1',
        ],
        [
            FALSE,
            '#1',
        ],
        [
            FALSE,
            '12',
        ],
        [
            FALSE,
            '#12',
        ],
        [
            TRUE,
            '123',
        ],
        [
            TRUE,
            '#123',
        ],
        [
            FALSE,
            '1234',
        ],
        [
            FALSE,
            '#1234',
        ],
        [
            FALSE,
            '12345',
        ],
        [
            FALSE,
            '#12345',
        ],
        [
            TRUE,
            '123456',
        ],
        [
            TRUE,
            '#123456',
        ],
        [
            FALSE,
            '1234567',
        ],
        [
            FALSE,
            '#1234567',
        ],
        // Tests valid hex value.
[
            TRUE,
            'abcdef',
        ],
        [
            TRUE,
            'ABCDEF',
        ],
        [
            TRUE,
            'A0F1B1',
        ],
        [
            FALSE,
            'WWW',
        ],
        [
            FALSE,
            '#123##',
        ],
        [
            FALSE,
            '@a0055',
        ],
        // Tests the data type.
[
            FALSE,
            123456,
        ],
        // Tests multiple hash prefix.
[
            FALSE,
            '###F00',
        ],
        // Tests spaces.
[
            FALSE,
            ' #123456',
        ],
        [
            FALSE,
            '123456 ',
        ],
        [
            FALSE,
            '#12 3456',
        ],
    ];
}

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