function HtmlTest::providerTestHtmlGetUniqueId

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestHtmlGetUniqueId()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestHtmlGetUniqueId()
  3. 10 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestHtmlGetUniqueId()

Provides test data for testHtmlGetId().

Return value

array Test data.

File

core/tests/Drupal/Tests/Component/Utility/HtmlTest.php, line 132

Class

HtmlTest
Tests \Drupal\Component\Utility\Html.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerTestHtmlGetUniqueId() {
    // cSpell:disable
    $id = 'abcdefghijklmnopqrstuvwxyz-0123456789';
    return [
        // Verify that letters, digits, and hyphens are not stripped from the ID.
[
            $id,
            $id,
        ],
        // Verify that invalid characters are stripped from the ID.
[
            'invalididentifier',
            'invalid,./:@\\^`{Üidentifier',
        ],
        // Verify Drupal coding standards are enforced.
[
            'id-name-1',
            'ID NAME_[1]',
        ],
        // Verify that a repeated ID is made unique.
[
            'test-unique-id',
            'test-unique-id',
            TRUE,
        ],
        [
            'test-unique-id--2',
            'test-unique-id',
        ],
        [
            'test-unique-id--3',
            'test-unique-id',
        ],
    ];
    // cSpell:enable
}

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