You are here

public function ConfigTest::validateNameProvider in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::validateNameProvider()
  2. 9 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 431

Class

ConfigTest
Tests the Config.

Namespace

Drupal\Tests\Core\Config

Code

public 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;
}