You are here

public function EntityTypeCRUDTest::testIfTooLongEntityTypeNamesAreCaughtInTime in Entity Construction Kit (ECK) 8

Drupal limits entity type names to 32 characters. This test ensures we also enforce that to prevent a white screen of death when a user creates an entity type with more than 32 character long name.

File

tests/src/Functional/EntityTypeCRUDTest.php, line 51

Class

EntityTypeCRUDTest
Tests if eck entity types are correctly created and updated.

Namespace

Drupal\Tests\eck\Functional

Code

public function testIfTooLongEntityTypeNamesAreCaughtInTime() {
  $this
    ->createEntityType([], 'a27CharacterLongNameIssLong');
  $label = 'a28CharacterLongNameIsLonger';
  $edit = [
    'label' => $label,
    'id' => $id = strtolower($label),
  ];
  $this
    ->drupalGet(Url::fromRoute('eck.entity_type.add'));
  $this
    ->submitForm($edit, 'Create entity type');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseContains("Machine name cannot be longer than <em class=\"placeholder\">27</em> characters but is currently <em class=\"placeholder\">28</em> characters long.");
}