You are here

public function CommentStringIdEntitiesTest::testCommentFieldNonStringId in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest::testCommentFieldNonStringId()

Tests that comment fields cannot be added entities with non-integer IDs.

File

core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php, line 42

Class

CommentStringIdEntitiesTest
Tests that comment fields cannot be added to entities with non-integer IDs.

Namespace

Drupal\Tests\comment\Kernel

Code

public function testCommentFieldNonStringId() {
  $this
    ->expectException(\UnexpectedValueException::class);
  $bundle = CommentType::create([
    'id' => 'foo',
    'label' => 'foo',
    'description' => '',
    'target_entity_type_id' => 'entity_test_string_id',
  ]);
  $bundle
    ->save();
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'foo',
    'entity_type' => 'entity_test_string_id',
    'settings' => [
      'comment_type' => 'entity_test_string_id',
    ],
    'type' => 'comment',
  ]);
  $field_storage
    ->save();
}