You are here

public function GroupTypeTest::testMaximumIdLength in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/GroupTypeTest.php \Drupal\Tests\group\Kernel\GroupTypeTest::testMaximumIdLength()

Tests the maximum ID length of a group type.

@covers ::preSave

File

tests/src/Kernel/GroupTypeTest.php, line 39

Class

GroupTypeTest
Tests the general behavior of group type entities.

Namespace

Drupal\Tests\group\Kernel

Code

public function testMaximumIdLength() {
  $this
    ->expectException(ConfigEntityIdLengthException::class);
  $this
    ->expectExceptionMessageRegExp('/Attempt to create a group type with an ID longer than \\d+ characters: \\w+\\./');
  $this->entityTypeManager
    ->getStorage('group_type')
    ->create([
    'id' => $this
      ->randomMachineName(GroupTypeInterface::ID_MAX_LENGTH + 1),
    'label' => 'Invalid ID length group type',
    'description' => '',
  ])
    ->save();
}