function ConfigEntityTypeTest::testConfigPrefixLengthValid

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

Tests when the prefix length is valid.

Tests that a valid config prefix returned by getConfigPrefix() does not throw an exception and is formatted as expected.

@covers ::getConfigPrefix

File

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

Class

ConfigEntityTypeTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityType[[api-linebreak]] @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testConfigPrefixLengthValid() : void {
  // A provider length of 24 and config_prefix length of 58 (+1 for the .)
  // results in a config length of 83, which is right at the limit.
  $definition = [
    'provider' => $this->randomMachineName(24),
    'config_prefix' => $this->randomMachineName(58),
  ];
  $config_entity = $this->setUpConfigEntityType($definition);
  $expected_prefix = $definition['provider'] . '.' . $definition['config_prefix'];
  $this->assertEquals($expected_prefix, $config_entity->getConfigPrefix());
}

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