function CommentStringIdEntitiesTest::testCommentFieldNonStringId
Same name in other branches
- 8.9.x core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest::testCommentFieldNonStringId()
- 10 core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest::testCommentFieldNonStringId()
- 11.x 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 45
Class
- CommentStringIdEntitiesTest
- Tests that comment fields cannot be added to entities with non-integer IDs.
Namespace
Drupal\Tests\comment\KernelCode
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.