function ConfigEntityTypeTest::testConfigPrefixLengthExceeds

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityTypeTest::testConfigPrefixLengthExceeds()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityTypeTest::testConfigPrefixLengthExceeds()
  3. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityTypeTest::testConfigPrefixLengthExceeds()

Tests when the prefix length exceeds the maximum defined prefix length.

Tests that we get an exception when the length of the config prefix that is returned by getConfigPrefix() exceeds the maximum defined prefix length.

@covers ::getConfigPrefix

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php, line 59

Class

ConfigEntityTypeTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21Entity%21ConfigEntityType.php/class/ConfigEntityType/9" title="Provides an implementation of a configuration entity type and its metadata." class="local">\Drupal\Core\Config\Entity\ConfigEntityType</a> @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testConfigPrefixLengthExceeds() {
    // A provider length of 24 and config_prefix length of 59 (+1 for the .)
    // results in a config length of 84, which is too long.
    $definition = [
        'provider' => $this->randomMachineName(24),
        'config_prefix' => $this->randomMachineName(59),
    ];
    $config_entity = $this->setUpConfigEntityType($definition);
    $this->expectException('\\Drupal\\Core\\Config\\ConfigPrefixLengthException');
    $this->expectExceptionMessage("The configuration file name prefix {$definition['provider']}.{$definition['config_prefix']} exceeds the maximum character limit of " . ConfigEntityType::PREFIX_LENGTH);
    $this->assertEmpty($config_entity->getConfigPrefix());
}

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