function ConfigTest::validateNameProvider

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::validateNameProvider()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::validateNameProvider()
  3. 10 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::validateNameProvider()

Provides data to test name validation.

See also

\Drupal\Tests\Core\Config\ConfigTest::testValidateNameException()

File

core/tests/Drupal/Tests/Core/Config/ConfigTest.php, line 439

Class

ConfigTest
Tests the Config.

Namespace

Drupal\Tests\Core\Config

Code

public static function validateNameProvider() {
    $return = [
        // Name missing namespace (dot).
[
            'MissingNamespace',
            'Missing namespace in Config object name MissingNamespace.',
        ],
        // Exceeds length (max length plus an extra dot).
[
            str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
            'Config object name ' . str_repeat('a', Config::MAX_NAME_LENGTH) . '. exceeds maximum allowed length of ' . Config::MAX_NAME_LENGTH . ' characters.',
        ],
    ];
    // Name must not contain : ? * < > " ' / \
    foreach ([
        ':',
        '?',
        '*',
        '<',
        '>',
        '"',
        "'",
        '/',
        '\\',
    ] as $char) {
        $name = 'name.' . $char;
        $return[] = [
            $name,
            "Invalid character in Config object name {$name}.",
        ];
    }
    return $return;
}

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