function SimpleConfigValidationTest::providerSpecialCharacters

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php \Drupal\KernelTests\Core\Config\SimpleConfigValidationTest::providerSpecialCharacters()

Data provider for ::testSpecialCharacters().

Return value

array[] The test cases.

File

core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php, line 82

Class

SimpleConfigValidationTest
Tests validation of certain elements common to all config.

Namespace

Drupal\KernelTests\Core\Config

Code

public static function providerSpecialCharacters() : array {
    $data = [];
    for ($code_point = 0; $code_point < 32; $code_point++) {
        $data["label {$code_point}"] = [
            'system.site',
            'name',
            mb_chr($code_point),
            'Labels are not allowed to span multiple lines or contain control characters.',
        ];
        $data["text {$code_point}"] = [
            'system.maintenance',
            'message',
            mb_chr($code_point),
            'Text is not allowed to contain control characters, only visible characters.',
        ];
    }
    // Line feeds (ASCII 10) and carriage returns (ASCII 13) are used to create
    // new lines, so they are allowed in text data, along with tabs (ASCII 9).
    $data['text 9'][3] = $data['text 10'][3] = $data['text 13'][3] = NULL;
    // Ensure emoji are allowed.
    $data['emoji in label'] = [
        'system.site',
        'name',
        '😎',
        NULL,
    ];
    $data['emoji in text'] = [
        'system.maintenance',
        'message',
        '🤓',
        NULL,
    ];
    return $data;
}

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