You are here

public function ConfigEntityTypeTest::testConfigPrefixLengthExceeds in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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 57

Class

ConfigEntityTypeTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityType @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());
}