You are here

public function ConfigTest::validateNameProvider in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 411
Contains \Drupal\Tests\Core\Config\ConfigTest.

Class

ConfigTest
Tests the Config.

Namespace

Drupal\Tests\Core\Config

Code

public function validateNameProvider() {
  $return = array(
    // Name missing namespace (dot).
    array(
      'MissingNamespace',
      'Missing namespace in Config object name MissingNamespace.',
    ),
    // Exceeds length (max length plus an extra dot).
    array(
      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 (array(
    ':',
    '?',
    '*',
    '<',
    '>',
    '"',
    "'",
    '/',
    '\\',
  ) as $char) {
    $name = 'name.' . $char;
    $return[] = array(
      $name,
      "Invalid character in Config object name {$name}.",
    );
  }
  return $return;
}